Use ADOX to conveniently query tables and fields

Source: Internet
Author: User

Test environment: WINXP + VB6

Add two list boxes and one 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 sub commandementclick ()

On Error resume next

For each TBL in cat. Tables

'If it is an 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 form_load ()

Set CNN = new ADODB. Connection

Set cat = new ADOX. Catalog

CNN. Open "provider = Microsoft. Jet. oledb.4.0; Data Source = F:/csdn_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 listmediaclick ()

Dim labels

Dim intfield as integer

List2.clear

Intfield = cat. Tables (list1.list (list1.listindex). Columns. Count

For I = 0 to intfield-1

Set keys = cat. Tables (list1.list (list1.listindex). Columns (I)

List2.additem metadata. Name & "& amp; consumer. Type & amp;" & amp; consumer. definedsize

Next

End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.