Autonumber Problem

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am using access with datadapter/dataset. The select command has a where
clause so I don't show all the records in the form. The problem is that when
I insert a new record (using currency manager addnew method), the autonumber
I get is the highest number in the current selection+1, not highest number
in the underlying table+1. This obviously causes a key violation. How can I
make my currency manager to get the correct next autonumber ID?

Thanks

Regards
 
You can set the Autoincrement property of a given datacolumn to -1 and set
the seed to 0. This way, you'll always have negative numbers. When you
update the DB, the DB will add new numbers according to its own autonumber
scheme, and you'll be good to go.

HTH,

Bill
 
See my article that discusses this in detail:
http://www.betav.com/msdn_magazine.htm.
hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
John,

See "Retrieving Identity or Autonumber Values" in the .NET
Framework SDK. There are examples using SQL Server and Access
with C# and VB.NET.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
Back
Top