TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dc
NA
663
0
C# access to to sql server table after update the table
Aug 24 2012 7:44 PM
In a C# 2010 application, I am trying to determine how and/or when I can obtain the identity key that was inserted into a table for a report that needs to be generated.
Basically in a linq to sql connection that connects to a sql server 2008 r2 database I have code that looks like the following:
db.Trans.InsertOnSubmit(trn);
db.Custs.InsertOnSubmit(cust);
db.SubmitChanges();
create_customer_report();
Basically in the line of code:
db.Trans.InsertOnSubmit(trn);
A new row is setup in the table called Trans. I do not believe the key to the table is actually updated in the database until the submitchanges() call is made.
In the line of code:
create_customer_report();
I need to add a line to the report in the create_customer_report method that includes the key to the table that was just inserted into the table from the code above.
I am concerned that I might not get the correct by doing a select max(key) from tran table since other users could be updating the table almost simultaneously in a different thread.
Thus my question is how can I obtain the key to the Trans table for the row that was just inserted into the table and have it appear on the customer_report?
Reply
Answers (
0
)
C# application use in Server2003 ?
Alphanumeric sorting