![]() |
Code to get the primary key of table using ADO and VBA
Dim db As New ADODB.Connection
Dim resultsRS As New ADODB.Recordset 'open your database connection first Function getPrimaryKeyName$(tableName$) Set resultsRS = db.OpenSchema(adSchemaPrimaryKeys, Array(Empty, Empty, tableName)) getPrimaryKeyName = resultsRS !COLUMN_NAME End Function I know that people often want to know how to do that (because I did) |
All times are GMT +1. The time now is 08:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com