VB rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic

[复制链接]
查看11 | 回复1 | 2008-7-5 11:37:11 | 显示全部楼层 |阅读模式
后面这个语句哪里有问题 我数据库用的ACCESS 但是不知道为什么运行的时候就提示 已经无效或者关闭! 谁能班我解决一下!谢谢了 急!!嗷嗷的!!
源代码如下:Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(txtuser.Text) = "" Then
'判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
txtuser.SetFocus
Else
sql = "select * from 系统管理 where 用户名='" & txtuser.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then

MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""

txtuser.SetFocus
Else
'检验密码是否正确

If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then

userID = txtuser.Text

userpow = rs_login.Fields(2)

rs_login.Close

Unload Me

Form1.Show

Else

MsgBox "密码不正确", vbOKOnly + vbExclamation, ""

txtpwd.SetFocus

End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
数据库名 book 加在哪?

回复

使用道具 举报

千问 | 2008-7-5 11:37:11 | 显示全部楼层
数据库都没打开怎么就开始查询记录了加上这段Set conn = New ADODB.Connectionconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=数据库名.mdb;Jet OLEDB:Database Password="加最前面,就是dim sql as string的前面。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行