设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3283|回复: 2
打印 上一主题 下一主题

关于ADO的问题?

[复制链接]
跳转到指定楼层
1#
发表于 2004-1-8 22:20:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我用VBA,想用ADO打开Northwind里面产品的表,程序如下:
Sub OpenADORecordset()
Dim cnNorthwind As ADODB.Connection
Dim rs产品 As New ADODB.Recordset
On Error GoTo ErrorHandler
Set cnNorthwind = New ADODB.Connection
cnNorthwind.Provider = "Microsoft.Jet.OLEDB.4.0"
code continued on next page
code continued from previous page
cnNorthwind.Open "D:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb"
Set rs产品 = New ADODB.Recordset
rs产品.Open "产品", cnNorthwind
Exit Sub
ErrorHandler:
MsgBox0 "An error occurred.  The error number is" & Err.Number & "and the description is" & Err.Description
Exit Sub
End Sub
运行的时候说,code continued on next page
code continued from previous page,这亮句缺少语句结束,该怎么改呢????
怎么样才能使Northwind里面产品的表出现在我的access表里面呢?????
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
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引用啊?
3#
发表于 2004-1-11 20:33:00 | 只看该作者
说句不好听的

明显不动脑子照抄代码


Sub OpenADORecordset()
Dim cnNorthwind As ADODB.Connection
Dim rs产品 As New ADODB.Recordset
On Error GoTo ErrorHandler
Set cnNorthwind = New ADODB.Connection
cnNorthwind.Provider = "Microsoft.Jet.OLEDB.4.0"
'code continued on next page 翻成中文:转下页
'code continued from previous page 翻译成中文:承上页
cnNorthwind.Open "D:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb"
Set rs产品 = New ADODB.Recordset
rs产品.Open "产品", cnNorthwind
Exit Sub
ErrorHandler:
MsgBox0 "An error occurred.  The error number is" & Err.Number & "and the description is" & Err.Description
Exit Sub
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-26 04:44 , Processed in 0.083959 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表