Dim dataname As String '新數据庫名
Dim cn1 As New ADODB.Connection
'''''''''''''''''''''''''''''''''''''''''''''''''''
Dim cat As New ADOX.Catalog
Dim newtable As String '新建數据表名稱
Dim newtb As New Table '新建數据表Public Sub openfile()
Set cn1 = Nothing '再次打開另一個數据庫時候.取消前一個數据庫
CommonDialog1.DialogTitle = "Please open a database file"
CommonDialog1.FileName = ""
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "Access database file MDB|*.mdb"
CommonDialog1.ShowOpen
dataname = CommonDialog1.FileName
If dataname = "" Then
MsgBox ("Database file open fail")
Exit Sub
Else
list1.Clear
cn1.open "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & CommonDialog1.FileName
Set Tables = cn1.OpenSchema(adSchemaColumns)
oldtablename = ""''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Do While Not Tables.EOF
If Tables("table_name") <> oldtablename Then
oldtablename = Tables("table_name")
list1.additem oldtablename
End If
Tables.MoveNext
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
If list1.ListCount = 0 Then
MsgBox ("Database file open fail")
Exit Sub
End If
list1.ListIndex = 0
Image1.Visible = False
DataGrid1.Visible = True
Toolbar1.Buttons(1).Enabled = True
End Sub以上是打開一個數据庫的代碼. list1是組合框.打開數据庫后. 在list1顯示該數据庫所有的數据表. 程序我用'號圍起來.問題是. 無論我打開一個有几個表的數据庫時候. list1都有MSysAccessObj;MSysIMEXColumns;MSysIMEXSpecs
這是啥東西啊! 這不像我要顯示的表名稱啊! 怎樣不要他們?
Dim cn1 As New ADODB.Connection
'''''''''''''''''''''''''''''''''''''''''''''''''''
Dim cat As New ADOX.Catalog
Dim newtable As String '新建數据表名稱
Dim newtb As New Table '新建數据表Public Sub openfile()
Set cn1 = Nothing '再次打開另一個數据庫時候.取消前一個數据庫
CommonDialog1.DialogTitle = "Please open a database file"
CommonDialog1.FileName = ""
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "Access database file MDB|*.mdb"
CommonDialog1.ShowOpen
dataname = CommonDialog1.FileName
If dataname = "" Then
MsgBox ("Database file open fail")
Exit Sub
Else
list1.Clear
cn1.open "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & CommonDialog1.FileName
Set Tables = cn1.OpenSchema(adSchemaColumns)
oldtablename = ""''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Do While Not Tables.EOF
If Tables("table_name") <> oldtablename Then
oldtablename = Tables("table_name")
list1.additem oldtablename
End If
Tables.MoveNext
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
If list1.ListCount = 0 Then
MsgBox ("Database file open fail")
Exit Sub
End If
list1.ListIndex = 0
Image1.Visible = False
DataGrid1.Visible = True
Toolbar1.Buttons(1).Enabled = True
End Sub以上是打開一個數据庫的代碼. list1是組合框.打開數据庫后. 在list1顯示該數据庫所有的數据表. 程序我用'號圍起來.問題是. 無論我打開一個有几個表的數据庫時候. list1都有MSysAccessObj;MSysIMEXColumns;MSysIMEXSpecs
這是啥東西啊! 這不像我要顯示的表名稱啊! 怎樣不要他們?
If left(Tables("table_name"),4)<>"MSys"Then
list1.additem Tables("table_name")
End If
Tables.MoveNext
Loop