用 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
当你使用 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
解决方案 »
- 如何对目录中的文件或子目录进行排序?按时间或按大小?
- sql 中的 bigint 类型时间 转换为标准时间
- MSHFlexGrid内容保存到Word文档的方法
- 如何將兩個LISTVIEW的記錄進行相互轉置
- 为什么老是吊线,公司的数据库应用程序。。。。
- 我又来了,接着上一个问题。如何得到除文件名以外的所有字符(盘符和路径)?
- Crystal ActiveX问题
- win2000下做的程序,在win me下安装不了,msvbvm60.dll有错,为什么?
- 送分啦!简单的API参数类型转换问题!快!
- Win2K+Vb6 +Ar2 中如何使用自定义纸张,急!
- 如何不让ActiveReport2.0在打印的时候分页?
- 关于怎样解决注册!
用 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
当你使用 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"