|
今天第一次出现了这种情况,查了半天也不知道什么原因
放上了论坛,大家指导一下.
运行环境
win10
office2016
打开记录集时用SQL语句,只能用星号代替字段名或者直接用表名
如果用字段名就出错.
如下过程出现:方法Open作用于Recordset对象失败
- Private Sub Command0_Click()
- Dim rs As New ADODB.Recordset
- Dim sSQL As String
- sSQL = "SELECT ORD.STYLE, ORD.PO, ORD.COLOR, ORD.SIZE, ORD.QUANTITY FROM ORD" '错误
-
- rs.Open sSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
-
- MsgBox rs.RecordCount
- rs.Close
- Set rs = Nothing
- End Sub
复制代码 而下面过程却运行正常,
- Private Sub Command1_Click()
- Dim rs As New ADODB.Recordset
- Dim sSQL As String
-
- sSQL = "SELECT * FROM ORD"
-
- rs.Open sSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly '运行正常
- ' rs.Open "ORD", CurrentProject.Connection, adOpenKeyset, adLockReadOnly '运行正常
-
- MsgBox rs.RecordCount
- rs.Close
- Set rs = Nothing
- End Sub
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|