Fog Creek Software
Discussion Board




autonumber again..

I believe Joel showed a technique where he appends the insert with a select @ID or the likes for sql server to get the last id added. I can not find the article/discussion.

How would one do the same on access via ado.net?

Karel
Friday, August 22, 2003

http://www.google.com/search?hl=&cat=&meta=&q=autonumber+ado.net

Damian
Friday, August 22, 2003

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/manidcrisis.asp

Everything you want to know about this.

I think that ADO .NET should really do this by itself, tough.

Joy
Friday, August 22, 2003

INSERT INTO Structure (NodeName, ParentID )
VALUES ('eee', 1); SELECT @@identity

@@identity should be an out parm and all is fine

tx for the pointers

Karel
Friday, August 22, 2003

Does anyone know a pre-.NET answer to the same question, though?  I have the "use a two-line stored procedure instead" method on my to-implement pile, but I'd be pleased if there was more graceful approach.

Mikayla
Friday, August 22, 2003

Now there are two parts to the question:  ADO vs. ADO.NET and Jet vs. MSDE.

I'm dealing with the same thing in VB6 using a Jet back-end and apparently ADO won't retrieve the autonumber ID from an MDB in Access 97 (Jet 3.51) format.  I switched to an Access 2000 (Jet 4) database and it works fine.  Not an option for everyone, but I couldn't get it to work any other way.

Sam Livingston-Gray
Friday, August 22, 2003

@@identity is not good, use SCOPE_IDENTITY()

na
Sunday, August 24, 2003

*  Recent Topics

*  Fog Creek Home