社区
VB基础类
帖子详情
怎么解决If rs.RecordCount>1 Then....但是它后面提示,如果对象已关闭,则不执行应用程序所要求操作。
smarter
2001-07-19 10:06:02
...全文
253
12
打赏
收藏
怎么解决If rs.RecordCount>1 Then....但是它后面提示,如果对象已关闭,则不执行应用程序所要求操作。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用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.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
rs
1.Open "select * from 密码 where
操作
员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic
If
rs
1.RecordCount > 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.RecordCount > 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.RecordCount > 0
Then
If
rs
1.RecordCount > 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
商品销售源码
VE
RS
ION 5.00 Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX" Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX" Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" Begin VB.Form main_jbxx_kh BackColor = &H00C0C0C0;& Borde
rS
tyle = 1 'Fixed Single Caption = "基本信息管理-【客户信息管理】" ClientHeight = 6165 ClientLeft = 1515 ClientTop = 2385 ClientWidth = 9195 Icon = "main_jbxx_kh.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 6165 ScaleWidth = 9195 StartUpPosition = 1 '所有者中心 Begin VB.Frame Frame3 Caption = "Frame6" Height = 690 Left = -1545 TabIndex = 11 Top = 2115 Visible = 0 'False Width = 2820 Begin MSAdodcLib.Adodc Adodc1 Height = 330 Left = 930 Top = 225 Width = 1590 _ExtentX = 2805 _ExtentY = 582 ConnectMode = 0 Cu
rs
orLocation = 3 IsolationLevel = -1 ConnectionTimeout= 15 CommandTimeout = 30 Cu
rs
orType = 3 LockType = 3 CommandType = 1 Cu
rs
orOptions = 0 CacheSize = 50 MaxRecords = 0 BOFAction = 0 EOFAction = 0 ConnectStringType= 1 Appearance = 1 BackColor = -2147483643 ForeColor = -2147483640 Orientation = 0 Enabled = -1 Connect = "Provider=MSDASQL.1;Pe
rs
ist Security Info=False;User ID=sa;Data Source=XSGL" OLEDBString = "Provider=MSDASQL.1;Pe
rs
ist Security Info=Fals
内部订单系统原代码
'定义一个数据访问类的
对象
Dim Password As String Dim db As New databases Dim
rs
As ADODB.Recordset '根据输入的用户名进行查询 Set
rs
= db.RunSelectSQL _ ("select 密码,姓名,权限,编号 from 用户清单 where 姓名 = '" _ + Me.txtUserName.Text + "'") '判断用户名是否存在
If
rs
.RecordCount = 0
Then
'用户名不存在 MsgBox "请输入正确用户名", , "
提示
" Me.txtUserName.Text = "" Me.txtPassword.Text = "" Else ' ''用户名存在 ' '获得用户的密码 Password =
rs
("密码") G_UserName = txtUserName.Text powe
rs
=
rs
("权限") bhao =
rs
("编号") '若是业务员用户禁止删除、添加、权限管理 用户功能 '判断密码是否正确
If
StrComp(Trim(Password), Trim(txtPassword.Text)) = 0 _ And txtPassword <> ""
Then
frmMain.Show '
执行
主窗口 Unload Me '
关闭
登录窗口
\vb-excel转换为mdb
vb-excel转换为mdb Private Sub Text1_DblClick() CDlg.DialogTitle = "打开 EXCEL 文件" CDlg.Filter = "所有 EXCEL 文件|*.xls" CDlg.ShowOpen
If
CDlg.FileName = ""
Then
Exit Sub Text1.Text = CDlg.FileName
If
Conn.State = adStateOpen
Then
Conn.Close Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Pe
rs
ist Security Info=False;Data Source=" & CDlg.FileName & ";Extended Properties='Excel 8.0;HDR=Yes'" '连接EXCEL文件 sql = "select * from [sheet1$]" '打开EXCEL表
rs
.Cu
rs
orLocation = adUseClient
rs
.Open sql, Conn, 3, 3 Label1.Caption = "共有记录: " &
rs
.RecordCount Set DataGrid1.Dat
ASP简单注册代码
一个ASP用户注册界面,用数据库实现
用户管理
ID
用户名
密码
<% set
rs
=server.CreateObject("adodb.recordset") sql="select * from use
rs
"
rs
.open sql,conn,1,1
if
rs
.recordcount=0
then
response.Write("
暂无用户记录
") else for i=1 to
rs
.recordcount response.Write("
"&
rs
("ID")&"
"&_ "
"&
rs
("用户名")&"
"&_ "
"&
rs
("密码")&"
")
rs
.movenext next end
if
%>
VB基础类
7,763
社区成员
197,605
社区内容
发帖
与我相关
我的任务
VB基础类
VB 基础类
复制链接
扫一扫
分享
社区描述
VB 基础类
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章