Use adox easy query tables and fields

xiaoxiao2021-03-06  62

Test environment: WinXP VB6

Add 2 list boxes, 1 button

'Reference Microsoft ADO EXT.2.X for DLL AND Security

DIM Cat as adox.catalog

DIM CNN As Adodb.Connection

DIM TBL AS Adox.Table

Private submmand1_click ()

ON Error ResMe next

For Each TBL in Cat.Tables

'If it is a SQLServer database, it becomes if left (tbl.name, 3) <> "sys"

IF Left (TBL.NAME, 4) <> "msys" then

List1.additem tbl.name

END IF

NEXT

End Sub

Private sub flow_load ()

Set cnn = new adodb.connection

SET CAT = New Adox.catalog

CNN.Open "provider = microsoft.jet.oledb.4.0; data source = f: /9cbs_vb/database/Article.mdb"

'cnn.open "provider = SQLOLEDB.1; PERSIST security info = false; user ID = sa; initial catalog = northwind; data source = yang"

Set cat.activeConnection = CNN

End Sub

Private Sub Form_Unload (Cancel AS Integer)

Set cat = Nothing

Set con = Nothing

End Sub

Private sub list1_click ()

DIM FLD

DIM INTFIELD AS INTEGER

List2.clear

INTFIELD = CAT.TABLES (List1.List (List1.ListIndex)). Columns.count

For i = 0 to intfield - 1

Set Fld = Cat.Tables (List1.list (List1.ListIndex)). Column (i)

List2.additem fld.name & "& fld.type &" & fld.definedsize

NEXT

End Sub

转载请注明原文地址:https://www.9cbs.com/read-118927.html

New Post(0)