Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the autoincrement no.
Message
From
18/01/2004 16:08:53
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
17/01/2004 01:56:59
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00867748
Message ID:
00867955
Views:
30
Mike,

For SQL Server:
SELECT ident_current('MyTable')+ident_incr('MyTable')
For a DataTable:
myDataSet.Tables("MyDataTable").Columns("MyPrimaryKeyColumn").AutoIncrementSeed + myDataSet.Tables("MyDataTable").Columns("MyPrimaryKeyColumn").AutoIncrementStep
Keep in mind that once a second connection to the SQL Server table is established, the next autoincrement number will become meaningless unless you enclose the entire data operation in a transaction.

Also, if you are using a Primary Key column in your DataTable that maps to an autoincremented field in the source database, the .NET auto-incremented values will be overwritten by the database when the row is INSERTED.

>Hi Guys,
>
>Is it possible to get the next autoincrement no. of a table before you insert a new record?
>
>Thanks....
Previous
Reply
Map
View

Click here to load this message in the networking platform