INSERT INTO Statement Error

  • I would use ASP.NET 2005, and simply go with the built-in user controls. there's just about zero coding required.

    Drop a formview control on the page, point the formview at the stored procedures for the table, and boom - pretty much instant read/edit/insert/delete form. Or any number of the other controls (gridview, detailview, etc...)

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • (trying this again).

    I would use ASP.NET 2005, and simply go with the built-in user controls. there's just about zero coding required.

    Drop a formview control on the page, point the formview at the stored procedures for the table, and boom - pretty much instant read/edit/insert/delete form. Or any number of the other controls (gridview, detailview, etc...)

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thanks.

    Where do I find ASP.NET 2005, and simply go with the built-in user controls. I have Visual Studio 2005. But I have only used it so far to build my tables.

    I assume what you reference can be found in that program interface someplace.

    HN

  • Thanks all for your input and corrections.

    I confess that the concepts mentioned (Scope_Identity and batchID) are at this time beyond my comprehension. Would you explain what these functions do and why I might consider using them?

  • Would someone suggest what asp.net or php code would allow me to view this record on a web page? My ultimate desire is to provide access to this and other tables via a web browser for inserts, updates, deletes and viewing.

    Thank you.

    HN

  • (trying this again).

    I would use ASP.NET 2005, and simply go with the built-in user controls. there's just about zero coding required.

    Drop a formview control on the page, point the formview at the stored procedures for the table, and boom - pretty much instant read/edit/insert/delete form. Or any number of the other controls (gridview, detailview, etc...)

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Matt,

    Where do I locate these controls you mention. I am using Visual Studio.

    Thanks,

    HN

  • Create a new ASP.NET web project. You should just see them in the toolbox when you do that.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Matt,

    I have found the .asp stuff thanks.

    Can you tell me what would cause following error that I get when i attempt to add a second record using SQL Insert Into?

    Msg 8152, Level 16, State 4, Line 2

    String or binary data would be truncated.

    I am using the same kind of insert that successfully added my first record.

  • check the lengths of variables before inserting their values into your tables

  • THANK YOU.

    You were SO correct.

  • I changed the database name from test to what I want to be the correct name. Now queries from the web indicate:

    "Cannot open database "New_name" requested by the login. The login failed.

    Loogin failed for user "NT Authority\Network service".

    The only thing I've done that I know is change the name of the database using SQL Server Management Studio.

    I must have to do something else, but what?

    I am the administrator of the server and I connect to it using remote desktop.

  • Open up your web.config file (from within the project editor). do a find for the old database name (it's in the connection string for the data). Replace with the new name.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • There are cases where I had to retrieve a record without knowing the uniqueidentifier that was generated by the default NEWID() setting.

    So I added an extra column Temp_OwnerID varchar(38) in which I inserted a GUID that is generated by the stored procedure, so it knows how to retrieve the new record(s).

    DECLARE @ls_OwnerID varchar(38)

    SET @ls_OwnerID = NEWID()

    INSERT INTO myTable (Temp_OwnerID, ... some other fields)

    SELECT @ls_OwnerID, ...

    FROM myAnotherTable

    To retrieve the new record(s) created

    SELECT * FROM myTable WHERE Temp_OwnerID = @ls_OwnerID

    So if it is not absolutely necessary, the primary key could be an integer with the identity flag set to 1.

    Regards

  • You should be able to if you remove the spurious ")" after your select list.

Viewing 15 posts - 16 through 29 (of 29 total)

You must be logged in to reply to this topic. Login to reply