Sql Server 2005 上的 GetOleDbSchemaTable 外键

发布于 2024-08-21 20:14:43 字数 394 浏览 4 评论 0原文

我正在尝试获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

べ繥欢鉨o。 2024-08-28 20:14:43

我不确定为什么 OleDb 会返回不正确的信息,但是您是否尝试过使用 SqlConnectionGetSchema 来代替?它们是 MSSQL 特定的,因此可能会产生更好的结果。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文