Sql Server 2005 上的 GetOleDbSchemaTable 外键
我正在尝试获取 SQL Server 2005 数据库中表的外键。我现在正在使用 GetOleDbSchemaTable 函数:
DataTable schemaTable = connection.GetOleDbSchemaTable(
OleDbSchemaGuid.Foreign_Keys,
new object[] { null, null, null, "TABLE" });
这会拉回正确的外键,唯一的问题是 UpdateRule 和 DeleteRule 设置为“无操作”。如果我浏览到 SSMS 中的同一个表,我可以看到我的删除规则是“设置 NULL”。 GetOleDbSchemaTable 函数是否未返回正确的外键规则?还有其他人遇到过这个问题吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定为什么 OleDb 会返回不正确的信息,但是您是否尝试过使用
SqlConnection
和GetSchema
来代替?它们是 MSSQL 特定的,因此可能会产生更好的结果。I'm not sure why OleDb would return incorrect information, but have you tried using
SqlConnection
andGetSchema
instead? They're MSSQL specific so may yield better results.