VB实时错误‘3705’"对象打开时,不允许操作 "

求高手指点调试adocon.Open"provider=microsoft.jet.oledb.4.0;datasource="&App.Path&""&"\tushu1... 求高手指点
调试adocon.Open "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "" & "\tushu1.mdb;persist security info=false"
语句错误
原代码
Option Explicit
Dim adocon As New ADODB.Connection
Dim mrc As New ADODB.Recordset

Private Sub Combo1_Change()
Text1.Text = ""
End Sub

Private Sub Command2_Click(Index As Integer)
Unload chaxun1
adocon.Close
End Sub

Private Sub Commandduo_Click()
Dim i, n As Integer
MSFlexGrid1.Clear
Select Case Combo1.ListIndex
Case Is = 0
Set mrc = Nothing
mrc.Open "select cfwz,sm,zz,cbs,bb,jg,bz from tushu where sm= '" & Text1.Text & "'", adocon, adOpenDynamic, adLockOptimistic

Case Is = 1
Set mrc = Nothing
mrc.Open "select cfwz,sm,zz,cbs,bb,jg,bz from tushu where zz= '" & Text1.Text & "'", adocon, adOpenDynamic, adLockOptimistic

Case Is = 2
Set mrc = Nothing
mrc.Open "select cfwz,sm,zz,cbs,bb,jg,bz from tushu where cbs= '" & Text1.Text & "'", adocon, adOpenDynamic, adLockOptimistic
End Select

If Text1.Text = "" Then
MsgBox " 请输入查找内容!", vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If

If Not mrc.EOF Then
MSFlexGrid1.Col = 1
MSFlexGrid1.Sort = flexSortStringAscending
MSFlexGrid1.TextMatrix(0, 0) = "位置"
i = 0
MSFlexGrid1.TextMatrix(i, 1) = "书名"
MSFlexGrid1.TextMatrix(i, 2) = "作者"
MSFlexGrid1.TextMatrix(i, 3) = "出版社"
MSFlexGrid1.TextMatrix(i, 4) = "版本"
MSFlexGrid1.TextMatrix(i, 5) = "价格"
MSFlexGrid1.TextMatrix(i, 6) = "备注"
While Not mrc.EOF
i = i + 1
MSFlexGrid1.TextMatrix(i, 0) = mrc.Fields(0).Value
MSFlexGrid1.TextMatrix(i, 1) = mrc.Fields(1).Value
MSFlexGrid1.TextMatrix(i, 2) = mrc.Fields(2).Value
MSFlexGrid1.TextMatrix(i, 3) = mrc.Fields(3).Value
MSFlexGrid1.TextMatrix(i, 4) = mrc.Fields(4).Value
MSFlexGrid1.TextMatrix(i, 5) = mrc.Fields(5).Value
MSFlexGrid1.TextMatrix(i, 6) = mrc.Fields(6).Value
mrc.MoveNext
Wend
Else
n = MsgBox("没有找到符合条件的记录,是否重新查找?", vbYesNo + vbInformation, "查找提示")
If n = vbYes Then
Text1.Text = ""
Text1.SetFocus
Else
Unload Me

End If
End If
End Sub

Private Sub Form_Load()
adocon.Open "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "" & "\tushu1.mdb;persist security info=false"
Text1.Text = ""
MSFlexGrid1.ColWidth(0) = 400
MSFlexGrid1.ColWidth(1) = 1800
MSFlexGrid1.ColWidth(2) = 1400
MSFlexGrid1.ColWidth(3) = 1300
MSFlexGrid1.ColWidth(5) = 400
End Sub
展开
 我来答
tq09tm5
2008-06-23 · TA获得超过141个赞
知道小有建树答主
回答量:1454
采纳率:0%
帮助的人:0
展开全部
mrc.Open "select cfwz,sm,zz,cbs,bb,jg,bz from tushu where zz= '" 类似你写的这些句子,表打开用完后要关掉(mrc。close),不然的话表已经打开了,你再去打开的话当然出错了
裔琦庞平卉
2019-09-01 · TA获得超过4785个赞
知道大有可为答主
回答量:3156
采纳率:34%
帮助的人:164万
展开全部
If
rs1.State
=
1
Then
rs1.Close
rs1.open
....
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
伟晖校梦山
2019-07-30 · TA获得超过4331个赞
知道大有可为答主
回答量:3011
采纳率:25%
帮助的人:175万
展开全部
Private
Sub
addhfText3_Click()
addhfid.Enabled
=
False
g_conn.Open
sql
=
"select
cusname
from
customer
where
cusid
=
'"
+
addhfid.Text
+
"'"
If
rss.State
<>
2
Then
rss.Close
rss.Open
sql,
g_conn,
1,
1
If
rss.EOF
Then
MsgBox
"客户不存在!",
vbInformation
Else
addhfText3.Text
=
rss("cusname")
End
If
addhfid.Enabled
=
True
rss.Close
g_conn.Close
End
Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式