How do I get the name Constraint?

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

Thanks in advance Madhu

0


a source to share


1 answer


From: How to use ADOX to determine if a primary key exists in 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

      

0


a source







All Articles