Copying tables that contain AutoNumber as PK - newbie question?

  • Thread starter Thread starter DN
  • Start date Start date
D

DN

I have some code that needs to copy a table from one database to
another using ADO (both tables might be Access, or possibly just the
destination table).

The tables are pretty simple:
EntryID (AutoNumber, PK)
Dir (int)
(more data...)

The two tables will never be in the same database, and often not even
of the same database type (ie might be going from MySQL to Access,
etc). With that in mind, I figured I'd just to a "select * from
table", and then for each row do an ADO AddNew, copy each individual
field value, and then do an ADO Update which should send the new row
to the table.

My problem is that I'm trying to specify a value for the EntryID
(AutoNumber) field. Unfortunately, there are other tables that also
get moved using the same process, and so I need to keep the EntryID
numbers the same so all relationships are maintained in the final
destination database.

Is this possible? Am I doing it the hard way? I'm hoping I don't
have to add all the new data and then somehow go back and remap all of
the relationships (although if it comes down to it, that's about all I
can figure).

Can anyone point me in the right direction?

Thanks
 
In your destination database, make the EntryID field LongInteger instead of
AutoNumber.
 
Back
Top