Solved

How to retrieve the Primary Key from an Access table?

Posted on 2002-05-03
5
538 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
Comment Utility
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
Comment Utility
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:mnasman
Comment Utility
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:
mnasman earned 500 total points
Comment Utility
0
 
LVL 7

Author Comment

by:JimMorgan
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now