开发者

GetOleDbSchemaTable Foreign Keys on Sql Server 2005

开发者 https://www.devze.com 2022-12-20 11:36 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消