ASP.NET 1.1 - Strongly Typed DataSets - how to insert/update?

Last post 06-11-2007 5:02 AM by Kevin Yu - MSFT. 1 replies.

Sort Posts:

  • ASP.NET 1.1 - Strongly Typed DataSets - how to insert/update?

    06-07-2007, 10:39 PM
    • Member
      point Member
    • franz1999
    • Member since 06-08-2007, 2:26 AM
    • Posts 1

    I created a multitable Strongly Typed Dataset. One table is "Customers" the other is "Addresses". The Addresses Table has a field "CustomerID" supposed to contain the PKID of the related Customer.

    How can I insert a new Customer and his Address in the DB using stored procs in Sql Server? Do I need to use 2 stored procs and pass to them as many parameter as many are the fields? Is there some better short cut? Should I GET the existing content of Customer and add a row into that and then call Update? How do I create the SELECT INSERT and DELETE commands?

    Overall a decent tutorial would be helpful. I read on 5 different books and MANY websites and tutorials but while they all talk about storngly typed dataset, no one is showing how to do an INSERT or an UPDATE in a multiple table strongly typed DS.


    Please advise!

    FG 

      

  • Re: ASP.NET 1.1 - Strongly Typed DataSets - how to insert/update?

    06-11-2007, 5:02 AM
    Answer

    Hi,

    Yes, you need to use 2 INSERT statements to insert both the customer and address information into 2 tables. Also it's good practice to put these 2 operations inside 1 transaction. You can also use SCOPE_IDENTITY() to get the newly generated identity when the 1st INSERT is done.

    Here is some others also doing this.

    http://groups.google.com/group/microsoft.public.vb.database.ado/browse_thread/thread/6773befd326e7d2e/a7c6667c2f49165d?lnk=st&q=INSERT+into+2+tables+transaction&rnum=3#a7c6667c2f49165d

    HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

    Sincerely,
    Kevin Yu
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Mark as Not Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (2 items)