Access 97 - getting Autonumber

J

Justin Weinberg

I thought I'd share my epiphany.

We have a client who is set on Access 97 for the time being. We can't
change that, nor the DB structure, since the rest of their architecture uses
it. The problem is getting the autonumber of an inserted record in ADO.NET.
It's a little clugee and violates ACID, but it's MS Access 97 anyway.

Insert a GUID into one of your string columns for the record and Select
where column=GUID. Rewrite insert queries as updates. This doesn't work
for tables without string columns of course.

Cute, huh?

--
Justin Weinberg

Designing a PrintDocument or creating .NET graphics?
Save time with GDI+ Architect.
For more information, visit http://www.mrgsoft.com
 
M

Miha Markic

Hi Justin,

You have to had all other columns null allowed, right?

Theoretical alternative would be to generate numbers by yourself (use normal
number column instead of autonumber) - you might put the last number used in
a special table.
Of course, if dropping autonumbering is posible choice.
 
J

Justin Weinberg

Yes, I wish I could change the structure of the tables. Unfortunately on
this project, that's not possible.
 

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