AutoIncrement field and jet

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
 
C

Cor

Hi Julian,

You can try this

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

Cor
 
W

William Ryan eMVP

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
 
P

Paul Clement

¤ 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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top