|
2#
楼主 |
发表于 2004-1-9 01:46:00
|
只看该作者
Sub OpenADORecordset()
'declare and instantiate the object variables
Dim cnNorthwind As ADODB.Connection
Dim rs产品 As ADODB.Recordset
On Error GoTo Error_Handler
'Set connection to a new Connection object
Set cnNorthwind = New Connection
cnNorthwind.Provider = "Microsoft.Jet.OLEDB.4.0"
'Open a connection to the Northwind database
cnNorthwind.Open "D:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb"
'Instantiate a new recordset object
Set rs产品 = New ADODB.Recordset
'Open the recordset and loop through the records
rs产品.Open "select * from 产品", cnNorthwind, adOpenStatic
Do Until rs产品.EOF
Debug.Print rs产品!产品名称
rs产品.MoveNext
Loop
Exit Sub
Error_Handler:
MsgBox ""
Exit Sub
End Sub
还是和上面一样呢?????我都有在VBA设置Microsoft ActiveX Data Object 2.1Libraary引用啊? |
|