Forum > Databases
Get primary keys of an Access database
(1/1)
RayoGlauco:
Hello,
I am connecting to an Access database (.accdb file) using ODBC.
I want to know what the primary key of a table is, but I can't find how to do it.
It seems that SQLPrimaryKeys is not supported by MS-Access ODBC drivers and then UpdateIndexDefs is not working.
Does anyone know how to get the primary key?
Thank you
Zvoni:
--- Quote from: RayoGlauco on February 13, 2024, 12:25:20 pm ---Hello,
I am connecting to an Access database (.accdb file) using ODBC.
I want to know what the primary key of a table is, but I can't find how to do it.
It seems that SQLPrimaryKeys is not supported by MS-Access ODBC drivers and then UpdateIndexDefs is not working.
Does anyone know how to get the primary key?
Thank you
--- End quote ---
Have you analyzed the FieldDefs?
That said:
AFAIK, Not possible with MS Access, since MS Access stores a Table's metadata in a binary blob inside a sys-table called "MSysObjects"
RayoGlauco:
If anyone is interested, I found a solution here:
https://forum.lazarus.freepascal.org/index.php/topic,28702.msg179953.html#msg179953
Navigation
[0] Message Index