Urgent !: Reset autoincrement Value ?

  • Thread starter Grigol Avetikov
  • Start date
G

Grigol Avetikov

Hi,
I have a datatable filled from MS Access database with autoincrement. field.
when i'm entering information everything is ok. But once I clear datatab;e
and open another database wich is empty and adding new records,
Autoincrement values continue from previous table values.For now it works so
that everytime i want to change database i have to close the programm and
run again , otherwise it does not reset the value of autoincrement field.
Example :
1 . I open db1.mdb with tbl1 table . there are rows with autoincrement
values from 1 to 10.
2 .I add new record and new autoincrement column value is 11.
3. Save table to database and clear datatable.
4. open another database (same scheme )where the table is empty.
5 Problem : add new record to empty table and autoincrement value is 12
instead of 1.
Question : How can i reset Autoincrement column in datatable next value to 1
?
 
M

Miha Markic [MVP C#]

Hi Grigol,

You should use negative values for newly assigned autoinc ids.
So you can distinguish real and temporary ones.
Also, it doesn't matter the value of temporary id (new rows) as it
will/should be replaced with database assigned one when you save to
database.
 

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