Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the autoincrement no.
Message
De
18/01/2004 16:08:53
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
17/01/2004 01:56:59
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00867748
Message ID:
00867955
Vues:
29
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....
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform