用 DAO 或 ADO 正确访问 Access 2000 
当你使用 DAO 访问 Access 2000 时,是否会出現以下的错误信息?"Run-time error 3343 Unrecognized Database Format XXX"这个错误信息有二个解決的方式:1、如果你是使用 Data Control 来连結 Access 2000 的资料库时:你必須在設定 Data Control 的 Source 前先加上一行
Set Data1.Recordset = rsDAO36 'rsDAO36 is a DAO 3.62、如果你是引用「Microsoft DAO 3.51 Object Library」来访问 Access 2000 的资料库时:請加入【工程】【部件】「Microsoft DAO 3.6 Object Library」
如果你是使用 ADO 访问 Access 2000以往在 VB6 中利用 ADO OLEDB Provider 3.51 使用 Access 97 資料库,程序都能正常的執行。但是自从將 Access 97 升級到 Access 2000 之后,就无法順利的使用 Access 2000 資料库了,不知道您是否也曾遇到这样的情形呢?其实这种事情在 Microsoft 已经是思空見慣的事情了!任何软件只要有了新的版本,就会有和旧版本不相容的问题产生!而這一次是因为 Access2000 己经使用 Jet 4.0 Engine,所以解決方法如下:
在您的 ADO 的 Connect String 中的 Provider 必須修改为:"PROVIDER=Microsoft,Jet.OLEDB.4.0" 
OpenRecordset Method ExampleThis example uses the OpenRecordset method to open five different Recordset objects and display their contents. The OpenRecordsetOutput procedure is required for this procedure to run.Sub OpenRecordsetX()   Dim wrkJet As Workspace
   Dim wrkODBC As Workspace
   Dim dbsNorthwind As Database
   Dim conPubs As Connection
   Dim rstTemp As Recordset
   Dim rstTemp2 As Recordset   ' Open Microsoft Jet and ODBCDirect workspaces, Microsoft 
   ' Jet database, and ODBCDirect connection.
   Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
   Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
   Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
   Set conPubs = wrkODBC.OpenConnection("", , , _
      "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")   ' Open five different Recordset objects and display the 
   ' contents of each.   Debug.Print "Opening forward-only-type recordset " & _
      "where the source is a QueryDef object..."
   Set rstTemp = dbsNorthwind.OpenRecordset( _
      "Ten Most Expensive Products", dbOpenForwardOnly)
   OpenRecordsetOutput rstTemp   Debug.Print "Opening read-only dynaset-type " & _
      "recordset where the source is an SQL statement..."
   Set rstTemp = dbsNorthwind.OpenRecordset( _
      "SELECT * FROM Employees", dbOpenDynaset, dbReadOnly)
   OpenRecordsetOutput rstTemp   ' Use the Filter property to retrieve only certain 
   ' records with the next OpenRecordset call.
   Debug.Print "Opening recordset from existing " & _
      "Recordset object to filter records..."
   rstTemp.Filter = "LastName >= 'M'"
   Set rstTemp2 = rstTemp.OpenRecordset()
   OpenRecordsetOutput rstTemp2   Debug.Print "Opening dynamic-type recordset from " & _
      "an ODBC connection..."
   Set rstTemp = conPubs.OpenRecordset( _
      "SELECT * FROM stores", dbOpenDynamic)
   OpenRecordsetOutput rstTemp   ' Use the StillExecuting property to determine when the 
   ' Recordset is ready for manipulation.
   Debug.Print "Opening snapshot-type recordset based " & _
      "on asynchronous query to ODBC connection..."
   Set rstTemp = conPubs.OpenRecordset("publishers", _
      dbOpenSnapshot, dbRunAsync)
   Do While rstTemp.StillExecuting
      Debug.Print "  [still executing...]"
   Loop
   OpenRecordsetOutput rstTemp   rstTemp.Close
   dbsNorthwind.Close
   conPubs.Close
   wrkJet.Close
   wrkODBC.CloseEnd SubSub OpenRecordsetOutput(rstOutput As Recordset)   ' Enumerate the specified Recordset object.
   With rstOutput
      Do While Not .EOF
         Debug.Print , .Fields(0), .Fields(1)
         .MoveNext
      Loop
   End WithEnd Sub
 

解决方案 »

  1.   


    用 DAO 或 ADO 正确访问 Access 2000 
    当你使用 DAO 访问 Access 2000 时,是否会出現以下的错误信息?"Run-time error 3343 Unrecognized Database Format XXX"这个错误信息有二个解決的方式:1、如果你是使用 Data Control 来连結 Access 2000 的资料库时:你必須在設定 Data Control 的 Source 前先加上一行
    Set Data1.Recordset = rsDAO36 'rsDAO36 is a DAO 3.62、如果你是引用「Microsoft DAO 3.51 Object Library」来访问 Access 2000 的资料库时:請加入【工程】【部件】「Microsoft DAO 3.6 Object Library」
    如果你是使用 ADO 访问 Access 2000以往在 VB6 中利用 ADO OLEDB Provider 3.51 使用 Access 97 資料库,程序都能正常的執行。但是自从將 Access 97 升級到 Access 2000 之后,就无法順利的使用 Access 2000 資料库了,不知道您是否也曾遇到这样的情形呢?其实这种事情在 Microsoft 已经是思空見慣的事情了!任何软件只要有了新的版本,就会有和旧版本不相容的问题产生!而這一次是因为 Access2000 己经使用 Jet 4.0 Engine,所以解決方法如下:
    在您的 ADO 的 Connect String 中的 Provider 必須修改为:"PROVIDER=Microsoft,Jet.OLEDB.4.0" 
     
    OpenRecordset Method ExampleThis example uses the OpenRecordset method to open five different Recordset objects and display their contents. The OpenRecordsetOutput procedure is required for this procedure to run.Sub OpenRecordsetX()   Dim wrkJet As Workspace
       Dim wrkODBC As Workspace
       Dim dbsNorthwind As Database
       Dim conPubs As Connection
       Dim rstTemp As Recordset
       Dim rstTemp2 As Recordset   ' Open Microsoft Jet and ODBCDirect workspaces, Microsoft 
       ' Jet database, and ODBCDirect connection.
       Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
       Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
       Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
       Set conPubs = wrkODBC.OpenConnection("", , , _
          "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")   ' Open five different Recordset objects and display the 
       ' contents of each.   Debug.Print "Opening forward-only-type recordset " & _
          "where the source is a QueryDef object..."
       Set rstTemp = dbsNorthwind.OpenRecordset( _
          "Ten Most Expensive Products", dbOpenForwardOnly)
       OpenRecordsetOutput rstTemp   Debug.Print "Opening read-only dynaset-type " & _
          "recordset where the source is an SQL statement..."
       Set rstTemp = dbsNorthwind.OpenRecordset( _
          "SELECT * FROM Employees", dbOpenDynaset, dbReadOnly)
       OpenRecordsetOutput rstTemp   ' Use the Filter property to retrieve only certain 
       ' records with the next OpenRecordset call.
       Debug.Print "Opening recordset from existing " & _
          "Recordset object to filter records..."
       rstTemp.Filter = "LastName >= 'M'"
       Set rstTemp2 = rstTemp.OpenRecordset()
       OpenRecordsetOutput rstTemp2   Debug.Print "Opening dynamic-type recordset from " & _
          "an ODBC connection..."
       Set rstTemp = conPubs.OpenRecordset( _
          "SELECT * FROM stores", dbOpenDynamic)
       OpenRecordsetOutput rstTemp   ' Use the StillExecuting property to determine when the 
       ' Recordset is ready for manipulation.
       Debug.Print "Opening snapshot-type recordset based " & _
          "on asynchronous query to ODBC connection..."
       Set rstTemp = conPubs.OpenRecordset("publishers", _
          dbOpenSnapshot, dbRunAsync)
       Do While rstTemp.StillExecuting
          Debug.Print "  [still executing...]"
       Loop
       OpenRecordsetOutput rstTemp   rstTemp.Close
       dbsNorthwind.Close
       conPubs.Close
       wrkJet.Close
       wrkODBC.CloseEnd SubSub OpenRecordsetOutput(rstOutput As Recordset)   ' Enumerate the specified Recordset object.
       With rstOutput
          Do While Not .EOF
             Debug.Print , .Fields(0), .Fields(1)
             .MoveNext
          Loop
       End WithEnd Sub
      

  2.   

    用 DAO 或 ADO 正确访问 Access 2000 
    当你使用 DAO 访问 Access 2000 时,是否会出現以下的错误信息?"Run-time error 3343 Unrecognized Database Format XXX"这个错误信息有二个解決的方式:1、如果你是使用 Data Control 来连結 Access 2000 的资料库时:你必須在設定 Data Control 的 Source 前先加上一行
    Set Data1.Recordset = rsDAO36 'rsDAO36 is a DAO 3.62、如果你是引用「Microsoft DAO 3.51 Object Library」来访问 Access 2000 的资料库时:請加入【工程】【部件】「Microsoft DAO 3.6 Object Library」
    如果你是使用 ADO 访问 Access 2000以往在 VB6 中利用 ADO OLEDB Provider 3.51 使用 Access 97 資料库,程序都能正常的執行。但是自从將 Access 97 升級到 Access 2000 之后,就无法順利的使用 Access 2000 資料库了,不知道您是否也曾遇到这样的情形呢?其实这种事情在 Microsoft 已经是思空見慣的事情了!任何软件只要有了新的版本,就会有和旧版本不相容的问题产生!而這一次是因为 Access2000 己经使用 Jet 4.0 Engine,所以解決方法如下:
    在您的 ADO 的 Connect String 中的 Provider 必須修改为:"PROVIDER=Microsoft,Jet.OLEDB.4.0" 
     
      

  3.   

    呵呵,我已经知道问题的答案了,原来是我同时引用了DAO和ADO库,真是冤啊,我花了不少时间才找到的:-(.不过还是要谢谢您写了这么详细的恢复,这里的高手真好啊!Thank You very much!!!