creating a primary key on a Access 2000 table
"Ruud Schmeitz" <[email protected]> Fri, 08 Aug 2003 02:04:35 -0000
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
Delphi 5 and MS Access 2000.
I use component BatchMove01 to make a copy of a table.
TBatchMove.Source = Table01
TBatchMove.Destination = Table02
TBatchMove.Mode = batCopy
The combination of Field01 and Field02 is the primary key of Table01,
and PrimaryKey is the name of the index for that primary key.
Unfortunately, the BatchMove01.execute "does not copy metadata
structures such as indexes (...)"
so Table02 does not have a primary key, or an index.
So I tried to create the primary key, using these statements:
Query1.SQL.Add ('ALTER TABLE Table02
ADD (PRIMARY KEY (Field01, Field02))');
Query1.ExecSQL;
but always get this error-message:
> General SQL error.
> [Microsoft][ODBC Microsoft Access Driver] Syntax error in field
> definition.
Perhaps the MS Access Required-property of Field01 and Field02 in
Table02 (which is set to No by default) has something to do with it ?
BTW, creating the index on both fields with these statements:
Query1.SQL.Add ('CREATE INDEX PrimKey ON Table02 (Field01, Field02)');
Query1.ExecSQL;
is no problem at all !
So the question is:
what Delphi-statements are required to create the primary key on a
MS Access 2000 tabel ?
Thanks in advance,
Ruud Schmeitz
Universiteit Maastricht
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/i7folB/TM
---------------------------------------------------------------------~->
CodeCoffer - new Delphi code protection Tool!
http://www.delphicollection.com/public/CodeCoffer.htm
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
---------------------------------------------------------------
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/