Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to retrieve the Primary Key from an Access table?

Posted on 2002-05-03
5
Medium Priority
?
552 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
[X]
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
  • 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 1500 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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