添加
個列表框
個按鈕
引用微軟 ADO Ext
X for dll and Security
Dim cat As ADOX
Catalog
Dim cnn As ADODB
Connection
Dim tbl As ADOX
Table
Private Sub Command
_Click()
On Error Resume Next
For Each tbl In cat
Tables
如果是sqlserver數據庫
則變成If Left(tbl
Name
) <>
sys
If Left(tbl
Name
) <>
MSys
Then
List
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
;Data Source=F:\csdn_vb\database\article
mdb
cnn
Open
Provider=SQLOLEDB
;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 List
_Click()
Dim fld
Dim intfield As Integer
List
Clear
intfield = cat
Tables(List
List(List
ListIndex))
Columns
Count
For i =
To intfield
Set fld = cat
Tables(List
List(List
ListIndex))
Columns(i)
List
AddItem fld
Name &
& fld
Type &
& fld
DefinedSize
Next
End Sub
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22061.html