473,480 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Find PrimaryKey in Recordset from ODBC

1 New Member
Set recordSet = New ADODB.recordSet
recordSet.Open SQL***, con, adOpenForwardOnly, adLockReadOnly, -1

I have got data from above SQL.
And I want to know which field is PrimaryKey at the table.

I tried to get that as below but got a error 91
Dec 11 '15 #1
2 1898
zmbd
5,501 Recognized Expert Moderator Expert
looks like you are missing some information in your post.

With a dao I would use:
CurrentDb.TableDefs("MyTable").Indexes("PrimaryKey ").Fields

you might find Allen's code helpful ShowSchema()

You might also find the adOpenForwardOnly to give you some issues...
Dec 11 '15 #2
mbizup
80 New Member
This will return the name of AutoIncrement fields in an ADODB recordset -- useful if your PK is set to auto increment:

Expand|Select|Wrap|Line Numbers
  1.  Dim rs As ADODB.Recordset
  2.  Set rs = New ADODB.Recordset
  3.  Dim fld As ADODB.Field
  4.  rs.Open "SELECT * FROM tblYourTable", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly, -1
  5.  For Each fld In rs.Fields
  6.     If fld.Properties("ISAUTOINCREMENT") = True Then Debug.Print fld.Name
  7.  Next fld
Dec 11 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
3730
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
11
17524
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
14
10096
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
6
6481
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
0
1186
by: sasan3 | last post by:
Let's say I have the following table: A B C D ----------- 1 1 1 6 1 1 2 7 2 2 3 8 2 2 4 9
4
85892
by: Lars E | last post by:
Hi all How can i set primarykey to a datatable. This datatable is in a dataset i get from a backend system. My datatable contains several fields, and i want to make the fields "c-custno1",...
8
9605
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
0
1278
by: rcamarda | last post by:
I have a machine with SQL Server 2000 loaded and I have the ODBC drivers for Excel listed in the ODBC (Administration Data Sources). Office is not loaded on this windows 2003 server. I have...
0
1913
by: massimof | last post by:
I have a 64 bits server hp-ux 11.11 and i need to connect it to DB2 using Odbc, but i didn't find the right odbc driver . Could you help me with a site where I can download odbc drivers for free ?...
0
1289
by: Bernd R. | last post by:
Hi, I am accessing an Access Database with VB.net 2005 with ADO.net. The data are displayed on a form in Text Boxes (there is no grid on the form). Now I'd like to place a ComboBox on the form...
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.