You can use the datareader as follows:
Dim cn as New OleDbConnection(strConnectString)
Dim cmd as New OleDbCommand
Dim myReader as OleDbDataReader
Dim dt as DataTable
Dim dRow as DataRow
Dim strPrimaryKeyList as String
cn.Open()
cmd.Connection = cn
cmd.CommandText = "Select * From yourTable"
myReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
dt = myReader.GetSchemaTable()
strPrimaryKeyList = ""
For Each dRow in dt.Rows
If dRow("IsKey") then
strPrimaryKeyList += dRow("ColumnName") & vbcrlf
End If
Next
cn.Close()
When done strPrimaryKeyList holds a list of the primary key field
names.
Hope that helps,
John
(PS I typed this in adHoc so check for typos, but you should get the
idea)