Solved

Open Schema Primary Key

Posted on 2004-08-30
3
335 Views
Last Modified: 2008-02-07
Hi

I am trying to know the primary key( I mean "PK" not "Required" ) of a table. In VB, Connection's OpenSchema(adOpenPrimaryKey) works fine with SQL Server and Oracle i.e. returns only those fields in the database which are Primary Keys in their respective Tables but when i use this function with MS Access it returns some binary values which are not understandable.
I need to know the primary key of a Table in MS Access on the fly using Visual Basic. Optional(The Schema should be returned as a Recordset as it is for SQL Server and Oracle)
On the web, i found a way through DAO's Table.Field.Index property, But i am using ADO 2.6.

I repeate again:
How to know the primary key of a table in MS Access on the fly using Visual Basic-ADO 2.6 ?

Thanks
0
Comment
Question by:AtifAqeel
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 50 total points
ID: 11930433
First, visit this page (one line):

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q186/2/46.asp&NoWebContent=1

Then it would be something like this:

  Set rst = CurrentProject.Connection.OpenSchema(adSchemaPrimaryKeys, Array(Empty, Empty, "YourTableName"))
  Debug.Print rst!COLUMN_NAME

/gustav
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 12265927
Did this work for you?

/gustav
0
 

Author Comment

by:AtifAqeel
ID: 12274903
yes it did
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

820 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