
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 展开
调试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 展开
3个回答
展开全部
mrc.Open "select cfwz,sm,zz,cbs,bb,jg,bz from tushu where zz= '" 类似你写的这些句子,表打开用完后要关掉(mrc。close),不然的话表已经打开了,你再去打开的话当然出错了

2024-04-12 广告
**ODU重载连接器**ODU重载连接器是一种高性能、高密度的连接解决方案,广泛应用于各种工业自动化和通信设备中。它采用先进的设计理念和制造技术,具有优异的电气性能和机械强度,能够满足复杂环境下对数据传输和信号稳定的高要求。同时,ODU重载...
点击进入详情页
本回答由上海莘默提供
展开全部
If
rs1.State
=
1
Then
rs1.Close
rs1.open
....
rs1.State
=
1
Then
rs1.Close
rs1.open
....
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询