Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW DO I PRINT CONSTRAINTS TO THE DEBUG WINDOW??

Status
Not open for further replies.

TNN

Programmer
Sep 13, 2000
417
US
Some time ago I created some constraints with the constraint clause. I have no idea what I did. Now I want to see what I put in. How do I print the constraints to the debug window????

I have used the OpenSchema method but cannot find the correct constant and rowset to print the constraint. I can print the constraint names but thats all. Seems like the constraint definition should be in the CONSTRAINT_CATALOG column but nothing prints.

This is an Access 2000 database.

Any help is appreciated. Thanks, TNN Tom
TNPAYROLL@AOL.COM


TOM
 
TNN Hi!

This is the code you should execute, but first change the strCnn to real connection string.

Dim cnn2 As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnn As String
Set cnn2 = New ADODB.Connection
strCnn = "Provider=SQLOLEDB.1;Persist Security " _
& "Info=False;User ID=sa;Initial Catalog=Northwind"
cnn2.Open strCnn
Set rstSchema = cnn2.OpenSchem(adSchemaTableConstraints)
Do Until rstSchema.EOF
Debug.Print rstSchema!TABLE_NAME & " " & _
rstSchema!CONSTRAINT_NAME & " " & _
rstSchema!CONSTRAINT_TYPE
rstSchema.MoveNext
Loop
rstSchema.Close
cnn2.Close
Set cnn2 = Nothing

If you want more details about the constraints see the adSchemaTableConstraints values on msdn.

If the result is empty it means that there are no constraints

I hope it helps

Yaakov
 
Yaakov,
Thank You for your reply. What you gave me still does not tell me what the constraint is doing. I am able to get all the items that your code mentions but what I cannot get is the syntax or a relation to the syntax that tells me what the constraint is doing. Much the same as when you bring up the definition of a stored procedure.
TNN, Tom
TNPAYROLL@AOL.COM

TOM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top