主要是以前有个程序,访问的是office97的数据库,现在不能访问2000的数据库,我想用ado替换原来的dao部分。

解决方案 »

  1.   

    现在若使用vb从头开发数据库应用,一般都使用ado,
    dao和rdo确实过时了
      

  2.   

    可以在 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
      

  3.   

    谢谢zhang_pi(zhangpi) 了,还没发现openschema这个好东东!这分怎么给你啊?