Hi,
I'm using a Access database with a dot.net application. To get last insert
Id(Autogenerated) from a specific tabel, I have used
"Select Max(Id) from table" to populate a datareader. I then use
"Reader.getint32" to get the id. This works fine when there is something in
the tabel. But when the table is empty I get a cast error, obviusly since
the Getint32 returns nothing. Is there a better way to get Last insert Id
from a Access database ?

TNX
Totto

Re: Getting last Insert ID by Miha

Miha
Thu Feb 05 04:48:12 CST 2004

Hi Totto,

Read this article:
HOW TO: Retrieve the Identity Value While Inserting Records into Access
Database By Using Visual C# .NET
http://tinyurl.com/2kmw8

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Totto" <taa.nospam1@norcon.no> wrote in message
news:uHSVDO96DHA.3648@TK2MSFTNGP11.phx.gbl...
> Hi,
> I'm using a Access database with a dot.net application. To get last insert
> Id(Autogenerated) from a specific tabel, I have used
> "Select Max(Id) from table" to populate a datareader. I then use
> "Reader.getint32" to get the id. This works fine when there is something
in
> the tabel. But when the table is empty I get a cast error, obviusly since
> the Getint32 returns nothing. Is there a better way to get Last insert Id
> from a Access database ?
>
> TNX
> Totto
>
>