Groups | Blog | Home
all groups > dotnet ado.net > september 2007 >

dotnet ado.net : Autonumber Issue With Access 2007 Database/ADO.NET


Jeff Gaines
9/13/2007 6:07:38 AM

I thought this may help other people learning ADO.NET.

Having, I thought, got a sufficient grip to 'go live' I set up an app
using Access 2007 and ADO.NET. During testing everything worked except my
'AddRecord' function, which kept complaining of a duplicate entry in an
indexed field. After writing and re-writing the app and tearing my hair
out I opened the table in Access, attempted to add a record and got the
same error. So 24 hours of frustration and it wasn't my code. It was the
database - it seemed to think it had only reached record 12 when it has
over 100 records in it. I changed the name of the AutoNumber field, added
a new one, deleted the old one and all works now.

So is lesson 99 check the Database manually if your code should work but
doesn't? As a very newcomer to ADO.NET my natural assumption was I had got
the code wrong!

--
PvdG42
9/13/2007 8:30:37 AM
[quoted text, click to view]


Excellent point and reminder :)
Rule 1 when a query appears not to work in an application is: try it direct
in the database, then look at your code if it works directly, but not via
your app.
wawang NO[at]SPAM online.microsoft.com (
9/14/2007 1:55:00 AM
Hi Jeff,

Thanks for sharing your experience here.

I'm sure every developer has similiar experience: sometimes something
simple just won't get right. Usually that's a good sign to get some sleep,
:)

Cheers,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button