Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to retrieve the Primary Key from an Access table?

Posted on 2002-05-03
5
543 Views
Last Modified: 2010-04-04
We are using ADO to retrieve tables from an Access DB.  ADO does not return the primary key like DAO did.  Does anyone have code to get the primary key of a table?

This is urgent - thus the bigger number of points.

Jim

PS I could use the answer in Delphi but will take VB.
0
Comment
Question by:JimMorgan
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 6989424
Here is the project and screenshot:
http://www.geocities.com/ameba_vb/temp/keys.html
If you have VB6 installed, find BIBLIO.MDB and copy it to c:\ - that should work with given connection
string.
0
 
LVL 15

Expert Comment

by:ameba
ID: 6989434
JimMorgan,
If my answer in VB topic area works, please ignore this one (I was only testing if I can post in the same minute as question is posted ;-)
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6989506
Hello

  Place DBGrid, ADOConnection,ADoDataset and datasource

connect the DBGrid with AdoDataset1 using the datasource

here's the code that will reterive the primary key, I got it from TeamB

ADOConnection1.OpenSchema(siPrimaryKeys,VarArrayOf([Null,Null,'urtable here']),EmptyParam,ADODataSet1);
adodataset1.Active := true;

you will see the primary key in the dbgrid

Best regards
Mohammed Nasman
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 500 total points
ID: 6989509
0
 
LVL 7

Author Comment

by:JimMorgan
ID: 6990137
mnasman,

Information that I obtained from the google posting got me on the right track.  At least I can now see the primary keys now.  I didn't give you an "A" because I had to do my own research and work to determine the right code.

Thanks,

Jim
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question