Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to get new ID with different system.data connections

Status
Not open for further replies.

SBGibson

Programmer
Apr 18, 2001
125
IT
Maybe this is not the right place but as I'm programming in c# for multiple database I'm trying here, if it's not good tell me where to write :)

This is the problem, I'm writing code for retrieving the last inserted autoincremental ID in a table in different databases.
I use sqlconnections and oracle connections.
I'm searching for a suggestion, it's better to use

begin trans
insert
select @@identity or select from sequence
commit

or

begin trans
insert
select max(id)
commit

What are the advanteges and disadvantages of the two solutions? sqlconnection and oracleconnection manage the two things in the same way? Select max is multiuser-safe?
There's a third way that is the best?

Thank in advance...I'm pretty confused :)

Stevie B. Gibson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top