?
Solved

How to retrieve the Primary Key from an Access table?

Posted on 2002-05-03
5
Medium Priority
?
547 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

764 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