AutoIncrement field and jet

  • Thread starter Thread starter Julian
  • Start date Start date
J

Julian

Hi

I wish to use a jet data base with an autoincrement field. How do you update
the database with the new rows added to the dataset and get the new
autoincrement number allocated by the db without refreshing the whole
dataset?

Many thanks

Julian
 
Hi Julian,

You can try this

da.update(ds)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds)

Cor
 
Check out Bill Vaugn's article on Managing an @@Identity Crisis
http://www.betav.com/msdn_magazine.htm (It's geared to SQL Server but the
same principle applies). You don't have to fire a Refresh for the whole
dataset, but each of the items you update, you'll need a SELECT command at
the end of it to get the values back. Remember to set the autoincrement
value to -1 and the seed to 0 so that you don't write the same values if
multiple users are running the app. In the DataAdapterConfiguration Wizard,
there's an option Refresh Dataset that will write the Update Statement for
you...even if you are rolling your own logic, it's a good way to see how
this works.

HTH,

Bill
 
¤ Hi
¤
¤ I wish to use a jet data base with an autoincrement field. How do you update
¤ the database with the new rows added to the dataset and get the new
¤ autoincrement number allocated by the db without refreshing the whole
¤ dataset?
¤

If you have a Jet 4.0 database (Access 2000 or higher) see the following:

http://msdn.microsoft.com/library/d...cpconRetrievingIdentityOrAutonumberValues.asp


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top