Solved

AutoIncrement Access from BDE

Posted on 1997-06-03
3
263 Views
Last Modified: 2010-04-06
Greetings,

We have an autoincrement field in a file (BDE/PARADOX) that has been set to a low value (how, is unknown at the moment).  We would like to be able to rewrite the header of the file so that the autoincrement field is set to a non-duplicate (proper) value again.  The code to get the largest existing value is a piece of cake.  The challenge is to rewrite the header with this value.  Anyone have any ideas?  The goal would be to write code to do this (rewrite the header).  We can not rewrite the file out since the autoincrement fields would be renumbered (other files need the existing numbers).

Thanks in advance....

John Wilson
Senior Software Engineer
PACS Software, Inc.
jwilson@pacsusa.com
0
Comment
Question by:PACS
3 Comments
 

Author Comment

by:PACS
ID: 1336793
This can be done through the database desktop by restructuring the table -- setting the minimum value for the auto-increment field, adding a record, and clearing the minimum value.  Would be nice to do in code though.  I've got the core of the program done... available BDE (doesn't work with normal Delphi calls) documentation is not good.  Any example of adding a minimum value to a file before the restructuring (dbidorestructure) in code would be useful.  jw (06/03/97).

0
 
LVL 1

Expert Comment

by:ygolan
ID: 1336794
John,

Just a suggestion - refrain from using Autoincrement fields as keys. If your table gets corrupted and you need to rebuild it, getting the BDE to use exactly the same values for the AI fields is very difficult.
0
 

Accepted Solution

by:
JGREER earned 200 total points
ID: 1336795
1. Rebuild the table (Autoincrement header info is either lost or incorrect.

2. Restructure the table setting the Autoincrement field(s) to 'I'nteger types.

3. Save the table.

4.  Restructure the table setting the Autoincrement field(s) back to AutoIncrement and save the table again.

5. The next record added will be last value +1

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now