如何获取约束的名称?

发布于 2024-07-21 18:27:12 字数 109 浏览 4 评论 0原文

我正在使用 MS Access 数据库并尝试从 C# 2.0 获取完整数据。 我如何使用 ADOX 获取约束名称(例如:主键的名称而不是主键的字段名称)。

提前致谢 马杜

I am using MS Access Database and trying to full data from C# 2.0.
How can i get the constriant name (Eg: name of Primarykey not the field name of primary key) using ADOX.

Thanks in advance
Madhu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

多像笑话 2024-07-28 18:27:12

来自:如何使用 ADOX 确定表中是否存在主键

SQL = "CREATE TABLE PKTEST1 (f1 INT PRIMARY KEY, f2 INT)"
cn.Execute SQL

Set cat.ActiveConnection = cn

'Check all indexes on the table for a primary key'
For Each idx In cat.Tables("PKTEST1").Indexes
        If idx.PrimaryKey = True Then
        Debug.Print "INDEX  NAME: " & idx.Name

        'Show all columns that make up the index'
        Debug.Print "consists of the following columns:"
        For i = 0 To idx.Columns.Count - 1
            Debug.Print idx.Columns(i).Name
        Next

    End If

Next

From: How To Use ADOX to Determine If a Primary Key Exists on a Table

SQL = "CREATE TABLE PKTEST1 (f1 INT PRIMARY KEY, f2 INT)"
cn.Execute SQL

Set cat.ActiveConnection = cn

'Check all indexes on the table for a primary key'
For Each idx In cat.Tables("PKTEST1").Indexes
        If idx.PrimaryKey = True Then
        Debug.Print "INDEX  NAME: " & idx.Name

        'Show all columns that make up the index'
        Debug.Print "consists of the following columns:"
        For i = 0 To idx.Columns.Count - 1
            Debug.Print idx.Columns(i).Name
        Next

    End If

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