怎么解决If rs.RecordCount>1 Then....但是它后面提示,如果对象已关闭,则不执行应用程序所要求操作。

smarter 2001-07-19 10:06:02
...全文
253 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
810303 2001-11-07
  • 打赏
  • 举报
回复
应该这样:
rs.CursorLocation = adUseClient
rs.Open "other", mainf.conn, adOpenKeyset, adLockPessimistic
smarter 2001-11-07
  • 打赏
  • 举报
回复
楼上的不要再说我了,
我不都给了你们吗?
要讲点信用对不对?
uguess 2001-11-07
  • 打赏
  • 举报
回复

又一个“保证不给分”的家伙!





baoxiang 2001-11-05
  • 打赏
  • 举报
回复
agree uguess(uguess) 
uguess 2001-11-05
  • 打赏
  • 举报
回复
看这段代码就知道了,他把Connection放到了Form_load 事件中,然后再其它的事件中在执行动作,但这个连接他定义的是局部变量!所以应该把定义改称模块变量就OK拉!
houtianxi 2001-11-05
  • 打赏
  • 举报
回复
你吧 regjts.Open "select * from bbbb", cnn, adOpenKeyset, adLockOptimistic, adCmdText该为
regjts.Open "select * from bbbb", cnn,adOpenStatic 试试
little_hero 2001-07-19
  • 打赏
  • 举报
回复
他给出的代码没错,只是没见到rs而已????
sosolong 2001-07-19
  • 打赏
  • 举报
回复
你试一下,在语句If rs.RecordCount>1 Then....前面加上一句:if rs is nothing then
endif 如果该表达式为true 则不要执行If rs.RecordCount>1 Then....了。
ar7_top 2001-07-19
  • 打赏
  • 举报
回复
没有看见你的上面出错的那句话啊
smarter 2001-07-19
  • 打赏
  • 举报
回复
没有啊,我把完整的事件过程给你看一下。Private Sub Form_Load()

Dim cnn As New ADODB.Connection
Dim regjts As New ADODB.Recordset


cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\vbw\xxcx.mdb;Jet OLEDB:Database Password=pwd;"
regjts.CursorLocation = adUseClient
regjts.Open "select * from bbbb", cnn, adOpenKeyset, adLockOptimistic, adCmdText
Set Adodc1.Recordset = regjts

End Sub

little_hero 2001-07-19
  • 打赏
  • 举报
回复
此前你肯定执行了rs.close关闭操作,导致你的rs.recordcount不存在!
zhhrlzm 2001-07-19
  • 打赏
  • 举报
回复
1、还没有打开连接
2、把连接关闭了
操作简单,适合小型手机店铺。Dim rs1 As New ADODB.Recordset Private Sub cmdexit_Click() frmmain.Visible = True Unload Me End Sub Private Sub cmdOK_Click() If txtuserid.Text = "" Then MsgBox "请输入操作员编号!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub Else rs1.Open "select * from 密码 where 操作员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If rs1.RecordCount > 0 Then txtusername.Text = Trim(rs1.Fields("操作员名称")) End If rs1.Close End If If txtusername.Text = "" Then MsgBox "操作员编号不存在!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub End If If txtoldpass.Text = "" Then MsgBox "请输入旧密码!", vbOKOnly + vbInformation, "修改密码" txtoldpass.SetFocus Exit Sub End If If txtnewpass.Text = "" Then MsgBox "请输入新密码!", vbOKOnly + vbInformation, "修改密码" txtnewpass.SetFocus Exit Sub End If If txtnewpass1.Text = "" Then MsgBox "请再次输入新密码!", vbOKOnly + vbInformation, "修改密码" txtnewpass1.SetFocus Exit Sub End If rs1.Open "select * from 密码 where 操作员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If rs1.RecordCount > 0 Then If txtoldpass.Text <> Trim(rs1.Fields("密码")) Then MsgBox "旧密码不正确!", vbOKOnly + vbInformation, "修改密码" txtoldpass.Text = "" txtoldpass.SetFocus Else If txtnewpass.Text = txtnewpass1.Text Then rs1.Fields("密码") = txtnewpass.Text rs1.Update MsgBox "密码修改成功!", vbOKOnly + vbInformation, "修改密码" rs1.Update txtuserid.SetFocus Else MsgBox "两次输入的密码不一致,请重新输入!", vbOKOnly + vbInformation, "修改密码" txtnewpass.Text = "" txtnewpass1.Text = "" txtnewpass.SetFocus End If End If End If rs1.Close End Sub Private Sub Form_Activate() txtuserid.SetFocus End Sub Private Sub txtNewPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnewpass1.SetFocus End If End Sub Private Sub txtNewPass1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdok.SetFocus End If End Sub Private Sub txtOldPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnewpass.SetFocus End If End Sub Private Sub txtUserId_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtoldpass.SetFocus End If End Sub Private Sub txtUserId_Change() txtusername.Text = "" txtoldpass.Text = "" txtnewpass.Text = "" txtnewpass1.Text = "" End Sub Private Sub txtuserid_LostFocus() rs1.Open "select * from 密码 where 操作员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If rs1.RecordCount > 0 Then If rs1.RecordCount > 0 Then txtusername.Text = Trim(rs1.Fields("操作员名称")) If txtusername.Text = "" Then MsgBox "操作员编号不存在!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub End If End If End If rs1.Close End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧