Hi,
i want to request Primary Keys from an OLE DB Tables. This works fine if my table has only one Primary Key. However, if the primary key is an composite key, the following function will only return true if the first part of the composite key is requested.
Any ideas to fix this problem Or to request all Primary Keys at once
Thanks,
Stefan
public Boolean isPrimary(int checkPos, String tableName)
{
DataTable mySchema = getConnectionPtr().GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new Object[] {null, null, tableName});
return (mySchema.Rows[0].ItemArray[3].ToString() == (String) getColumNames()[checkPos]);
}

How to request Primary Keys from OLE DB Table
wdudek
Liam .net
The following works fine for me (lists all column names in the primary key):
Dim DatabaseConnection As New System.Data.OleDb.OleDbConnection
Dim SchemaTable As DataTable
DatabaseConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Test Files\db1 XP.mdb"
DatabaseConnection.Open()
SchemaTable = DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Primary_Keys, _
New Object() {Nothing, Nothing, "TestKeyTable"})
Dim RowCount As Int32
For RowCount = 0 To SchemaTable.Rows.Count - 1
Next RowCount
DatabaseConnection.Close()
Rizzlers
StephanieR
Is this working for you now I noticed your post in the Microsoft NNTP newsgroup microsoft.public.dotnet.framework.adonet.
Lawrence Kok
Shirvo
What type of database are you working with Are you referring to the columns of which the primary key is comprised