dcsimg
Results 1 to 4 of 4

Thread: sql transaction

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    sql transaction

    here is the link where sql transaction is used http://www.aspnettutorials.com/tutor...on-csharp.aspx

    in this line
    Code:
    myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";
    RegionID is entered by user rather than auto generated ,so i have same problem but only difference is that if i have auto generated what code should i write in try block .

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: sql transaction

    Hey,

    If you want the RegionID to be specified by the user, then you will need to created a parameterized query, and get this value from the user.

    Have a look here:

    http://www.4guysfromrolla.com/webtech/092601-1.shtml

    For more information.

    Gary

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    270

    Re: sql transaction

    no ,not specified by user see first region details enters by user and region id is created in Database automatically (auto generated primary field in table).means enter in region table and get the same record from region table in order to enter the data into another table based on the same regionid

    please provide feedabck if still need description

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: sql transaction

    Ah, ok, I think I see what you are getting at.

    You can use the Scope_Identity to get the last value entered in the table:

    http://msdn.microsoft.com/en-us/library/ms190315.aspx

    From there, you can use this value in the updates to the other tables.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width