Autonumber Issue With Access 2007 Database/ADO.NET

  • Thread starter Thread starter Jeff Gaines
  • Start date Start date
J

Jeff Gaines

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!
 
Jeff Gaines said:
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!


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.
 
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 ([email protected], 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.
 
Back
Top