using ado to get the Primary Key Column name from MS ACCESS RRS feed

  • Question

  • Hello ,

    I am trying to get the Column names from all the tables which are PRIMARY KEYS ONLY.  I have tried the following ..

    _ConnectionPtr m_pConnectionPtr = NULL;

    _Recordsettr m_pRecordsetPtr = NULL


    m_pRecordSet = m_pConnection->OpenSchema(adSchemaTables)

    .. Then I have googled so many sites but iam not able to get the information. Can some please five me a Clue.


    Friday, December 13, 2019 2:11 PM

All replies

  • Did you check the returned results, i.e. rows and columns of m_pRecordSet? Consider typical approach that is used to read regular table data.

    According to documentation, it should return a self-descriptive information. One of the columns will probably define the primary key, and each row will correspond to a column of queried table.

    Maybe call m_pRecordSet->Save with XML format to investigate the available columns manually. Then use the found names that corresponds to Primary Key.

    Friday, December 13, 2019 4:08 PM
  • Use adSchemaPrimaryKeys





    Friday, December 13, 2019 5:30 PM
  • Hello,

    If your issue is solved, please "Mark as answer" or "Vote as helpful" post to the appropriate answer , so that it will help other members to find solution quickly if they faces similar issue.

    Best Regards,

    Suarez Zhou

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, December 20, 2019 7:04 AM