Board index » delphi » Using MSACCESS autoincrement fields via BDE

Using MSACCESS autoincrement fields via BDE

I'm actually writing a program which populates a MSACCESS table.
My problem is how to reset the autoincrement field, because even if I
empty the table, using the EmptyTable() method, the value of the first
record then inserted, doesn't start from 0.
I want it to start from 0.
How ?

 

Re:Using MSACCESS autoincrement fields via BDE


Hi.  I'm sure there are better ways but you could just delete the field
after emptying it and then re-insert the autoincrement field.  When new
records are then added you should find that the counter is reset.

Something like an SQL "ALTER TABLE tablename DROP COLUMN [FieldName]" should
do it.

"ALTER TABLE tablename ADD [FieldName] AutoIncrement" should I think place
it back.  You may have other properties etc. you wish to set but off the top
of my head this should work.

Well, probably.

Andy

Re:Using MSACCESS autoincrement fields via BDE


Quote
you wrote:
>Hi.  I'm sure there are better ways but you could just delete the field
>after emptying it and then re-insert the autoincrement field.  

Hmmm, I don't like this technique very much ;)
I should probably compact the MSACCESS table.
But how can I compact a MSACCESS database using BDE ?

Re:Using MSACCESS autoincrement fields via BDE


The official way is described in
http://msdn.microsoft.com/library/officedev/off2000/achowChangeStarti...
AutoNumberFieldS.htm

"Kalem J. Norey" <k...@programmers.com> schreef in bericht
news:38f343e2.7803080@news.libero.it...

Quote
> you wrote:

> >Hi.  I'm sure there are better ways but you could just delete the field
> >after emptying it and then re-insert the autoincrement field.

> Hmmm, I don't like this technique very much ;)
> I should probably compact the MSACCESS table.
> But how can I compact a MSACCESS database using BDE ?

Other Threads