Solved

How to retrieve the Primary Key from an Access table?

Posted on 2002-05-03
5
542 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

815 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

10 Experts available now in Live!

Get 1:1 Help Now