社区
VB基础类
帖子详情
怎么解决If rs.RecordCount>1 Then....但是它后面提示,如果对象已关闭,则不执行应用程序所要求操作。
smarter
2001-07-19 10:06:02
...全文
265
12
打赏
收藏
怎么解决If rs.RecordCount>1 Then....但是它后面提示,如果对象已关闭,则不执行应用程序所要求操作。
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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
rs
1 As New ADODB.
Record
set 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
rs
1.Open "select * from 密码 where
操作
员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If
rs
1.
Record
Count
> 0 Then txtusername.Text = Trim(
rs
1.Fields("
操作
员名称")) End If
rs
1.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
rs
1.Open "select * from 密码 where
操作
员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If
rs
1.
Record
Count
> 0 Then If txtoldpass.Text <> Trim(
rs
1.Fields("密码")) Then MsgBox "旧密码不正确!", vbOKOnly + vbInformation, "修改密码" txtoldpass.Text = "" txtoldpass.SetFocus Else If txtnewpass.Text = txtnewpass1.Text Then
rs
1.Fields("密码") = txtnewpass.Text
rs
1.Update MsgBox "密码修改成功!", vbOKOnly + vbInformation, "修改密码"
rs
1.Update txtuserid.SetFocus Else MsgBox "两次输入的密码不一致,请重新输入!", vbOKOnly + vbInformation, "修改密码" txtnewpass.Text = "" txtnewpass1.Text = "" txtnewpass.SetFocus End If End If End If
rs
1.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()
rs
1.Open "select * from 密码 where
操作
员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If
rs
1.
Record
Count
> 0 Then If
rs
1.
Record
Count
> 0 Then txtusername.Text = Trim(
rs
1.Fields("
操作
员名称")) If txtusername.Text = "" Then MsgBox "
操作
员编号不存在!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub End If End If End If
rs
1.Close End Sub
VB ADODB的小程序(代码)五.rar
VB ADODB SQL 精确查找并排序、模糊查询并排序、随机提取多条记录、统计记录总数(精确查找并排序、模糊查询并排序、随机提取多条记录、统计记录总数)
VB与SQL+Server连接[参照].pdf
VB与SQL+Server连接[参照].pdf
VB与各数据库的几种连接方式
主要是DAO和ADO与Access、DBF、Excel、Oracle、SQLserver等数据库的连接方法。合适初学者!
在ASP中轻松实现记录集分页显示
在ASP中轻松实现记录集分页显示,超酷
VB基础类
7,785
社区成员
197,585
社区内容
发帖
与我相关
我的任务
VB基础类
VB 基础类
复制链接
扫一扫
分享
社区描述
VB 基础类
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章