I have a connection to an Access DB with ADO.
How can I get the Primary Key name field with ADO ?
Printable View
I have a connection to an Access DB with ADO.
How can I get the Primary Key name field with ADO ?
here ya go
Code:Dim cn As ADODB.Connection
Dim ax As ADOX.Catalog
Dim tbl As ADOX.Table
Dim ky As ADOX.Key
Set cn = New Connection
cn.Open "Provider=Microsoft.JET.OLEDB.4.0;Data Source=Nwind.mdb"
Set ax = New Catalog
ax.ActiveConnection = cn
Set tbl = ax.Tables("Customers")
For Each ky In tbl.Keys
MsgBox ky.Type 'returns KeyTypeEnum
Next ky
'cleanup.....