可以在 ado 数据源的一个属性里检索这个数据源有那些表或视图。 Dim sor, t1, t2, t0, tB, TypeID As String Dim i, j, k, l, m, n As Integer sor = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathNameTxt.Text & ";" Dim mServer As New ADODB.Connection mServer.CursorLocation = adUseClient mServer.Open sor Dim adopr1 As New ADODB.Recordset Set adopr1 = mServer.OpenSchema(adSchemaTables) j = adopr1.RecordCount adopr1.MoveFirst For i = 1 To j t1 = adopr1.Fields("table_name").Value t2 = adopr1.Fields("table_type").Value If t1 = "A001A002" And t2 = "TABLE" Then tB = t1 TypeID = Right(tB, 4) Exit For End If If t1 = "A001A001" And t2 = "TABLE" Then tB = t1 TypeID = Right(tB, 4) Exit For End If adopr1.MoveNext Next i
dao和rdo确实过时了
Dim sor, t1, t2, t0, tB, TypeID As String
Dim i, j, k, l, m, n As Integer
sor = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathNameTxt.Text & ";"
Dim mServer As New ADODB.Connection
mServer.CursorLocation = adUseClient
mServer.Open sor
Dim adopr1 As New ADODB.Recordset
Set adopr1 = mServer.OpenSchema(adSchemaTables)
j = adopr1.RecordCount
adopr1.MoveFirst For i = 1 To j
t1 = adopr1.Fields("table_name").Value
t2 = adopr1.Fields("table_type").Value If t1 = "A001A002" And t2 = "TABLE" Then
tB = t1
TypeID = Right(tB, 4)
Exit For
End If If t1 = "A001A001" And t2 = "TABLE" Then
tB = t1
TypeID = Right(tB, 4)
Exit For
End If adopr1.MoveNext
Next i