首页上一页 1 下一页尾页 3 条记录 1/1页
SQL2000中的表无法打开
发表在VB答疑区
2009-08-13
是否精华
是
否
版块置顶:
是
否
代码如下,实现的是一个登陆的界面,输入用户名和密码,和数据库中的比对,数据库中已经存在数据了, 但Rs.EOF = True 一直成立,原因何在?
Dim sql As String, cunt As Integer
Dim Rs As ADODB.Recordset
If Trim(txtusername.Text) = "" Then
MsgBox "没有输入用户名称,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Exit Sub
Else
Set Rs = New ADODB.Recordset
sql = "select * from Admin where (username=' " & Trim(txtusername.Text) _
& "') and (password='" & Trim(txtpassword.Text) & "')"
Rs.Open sql, conn, adOpenKeyset, adLockOptimistic
cunt = Rs.RecordCount
If Rs.EOF = True Then
MsgBox "用户名或密码错误,请重新输入", vbOKOnly + vbExclamation, "警告"
txtusername.Text = ""
txtpassword.Text = ""
txtusername.SetFocus
Rs.Close
Exit Sub
Else
currentuser = txtusername.Text
utype = Rs.Fields("usertype")
Unload Me
MDIForm1.Show
End If
End If
Dim sql As String, cunt As Integer
Dim Rs As ADODB.Recordset
If Trim(txtusername.Text) = "" Then
MsgBox "没有输入用户名称,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Exit Sub
Else
Set Rs = New ADODB.Recordset
sql = "select * from Admin where (username=' " & Trim(txtusername.Text) _
& "') and (password='" & Trim(txtpassword.Text) & "')"
Rs.Open sql, conn, adOpenKeyset, adLockOptimistic
cunt = Rs.RecordCount
If Rs.EOF = True Then
MsgBox "用户名或密码错误,请重新输入", vbOKOnly + vbExclamation, "警告"
txtusername.Text = ""
txtpassword.Text = ""
txtusername.SetFocus
Rs.Close
Exit Sub
Else
currentuser = txtusername.Text
utype = Rs.Fields("usertype")
Unload Me
MDIForm1.Show
End If
End If