views:

147

answers:

1

I'm trying to get the Foreign Keys for a table in my SQL Server 2005 database. I'm using the GetOleDbSchemaTable function right now:

DataTable schemaTable = connection.GetOleDbSchemaTable(
        OleDbSchemaGuid.Foreign_Keys,
        new object[] { null, null, null, "TABLE" });

This pulls back the right foreign keys, the only problem is that the UpdateRule and DeleteRule are set to "No Action". If I browse to the same table in SSMS I can see that my DeleteRule is "Set NULL". Does the GetOleDbSchemaTable function not return the proper foreign key rules ? Has any one else ran into this problem ?

A: 

I'm not sure why OleDb would return incorrect information, but have you tried using SqlConnection and GetSchema instead? They're MSSQL specific so may yield better results.

Sam