Database Schema using ADOX

Using ADOX along with ADO, you can do everything you could with DAO. Such as Creating Databases and Stored Procedures, and the usual abilities of Selecting, Inserting, Updating, and Deleting data. ADOX even adds a bunch of the SQL-DMO functionality.

The attached code is a sample that prints all the tables and their respective columns in the selected database to the Debug window in VB6.

Set cn = New ADODB.Connection
Set cat = New ADOX.Catalog
Set col = New ADOX.Column
Set tbl = New ADOX.Table
Set dl = New DataLinks

dl.hWnd = Me.hWnd 'Make the current form the datalinks parent form (if the parent unloads, the child does too)
sConnString = dl.PromptNew

If sConnString <> "" Then

cn.ConnectionString = sConnString 'set the connection string of the ADODB.connection object to the connection string generated by the datalinks
If cn.State = 0 Then cn.Open 'if the connection is closed, open it.
Set cat.ActiveConnection = cn 'set the adox's active conneciton to the ADODB.Connection

by carlos-chacon (0 replies)

by grabbitmedia (0 replies)

Published 4 years ago, running time 0h54m

Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.