Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
If I have an object that has been updated with user data and then the objects .Add method is called to create the record in the Access database then is there any easy way of getting the AutoNumber generated by Access other than finding a way to read back in the new record?
My website
Posted
No hog, you can do that if only user is using your application at a time and thus you would fetch the maximum id from the Access database upon filling the dataset. But ofcourse if more than one user is using your application then this number would be meaningless since new rows are added all the time
Dream as if you'll live forever, live as if you'll die today
  • *Experts*
Posted

I heard differently awhile back. If you issue two separate calls to Access, one to do the INSERT and one to do the "SELECT @@IDENTITY" to get the last inserted AutoNumber value, it should work. This assumes each user has their own always-on connection to the DataBase (usually how you program against Access).

 

It's a bit easier in SQL Server since you can do the INSERT and SELECT @@IDENTITY in one calls, but it doesn't work in Access for dynamic SQL. If you're calling a stored proc in Access (which you must create using dynamic sql using something like "CREATE PROC...", you *might* be able to have the proc do an INSERT and SELECT, but I haven't tried it (nor have I tried creating procs in Access, though I hear-tell you can).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Thx Nerseus:)

 

I have decided to take a different approach to solve this issue. However you points will be noted as this is the second time I've required this, so you never know:) :)

My website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...