GetOleDbSchemaTable Foreign Keys on Sql Server 2005
I'm trying to get the Foreign Keys for a tabl开发者_Python百科e 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 ?
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.
精彩评论