Recent

Author Topic: Get primary keys of an Access database  (Read 482 times)

RayoGlauco

  • Full Member
  • ***
  • Posts: 183
  • Beers: 1567
Get primary keys of an Access database
« 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
To err is human, but to really mess things up, you need a computer.

Zvoni

  • Hero Member
  • *****
  • Posts: 2364
Re: Get primary keys of an Access database
« Reply #1 on: February 13, 2024, 12:40:19 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
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"
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

RayoGlauco

  • Full Member
  • ***
  • Posts: 183
  • Beers: 1567
Re: Get primary keys of an Access database
« Reply #2 on: February 13, 2024, 03:21:39 pm »
To err is human, but to really mess things up, you need a computer.

 

TinyPortal © 2005-2018