N
news.microsoft.com
I have the following code that gets the primary and foreign keys from the
tables in my database. This works fine for tables that have only one
foreign key. My question is if a table has multiple foreign keys or
multiple columns make up one foreign key, will there be multiple rows coming
back from GetOleDbSchemaTable or will I have to look at several fields?
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Foreign_Keys, null);
foreach (DataRow dr in dt.Rows)
{
// get primary/foreign table and column names
string pkTableName = BracketName((string)dr["PK_TABLE_NAME"]);
string fkTableName = BracketName((string)dr["FK_TABLE_NAME"]);
string pkColumnName = BracketName((string)dr["PK_COLUMN_NAME"]);
string fkColumnName = BracketName((string)dr["FK_COLUMN_NAME"]);
Thanks
Bill
tables in my database. This works fine for tables that have only one
foreign key. My question is if a table has multiple foreign keys or
multiple columns make up one foreign key, will there be multiple rows coming
back from GetOleDbSchemaTable or will I have to look at several fields?
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Foreign_Keys, null);
foreach (DataRow dr in dt.Rows)
{
// get primary/foreign table and column names
string pkTableName = BracketName((string)dr["PK_TABLE_NAME"]);
string fkTableName = BracketName((string)dr["FK_TABLE_NAME"]);
string pkColumnName = BracketName((string)dr["PK_COLUMN_NAME"]);
string fkColumnName = BracketName((string)dr["FK_COLUMN_NAME"]);
Thanks
Bill