跪求高手帮忙 (好急)SQL与VB连接问题

来源:百度知道 编辑:UC知道 时间:2024/06/14 07:06:51
Private Sub cmdOK_Click()
Dim i As Integer
If ConnectSQL(txtUserName.Text) = True Then
MsgBox "连接成功", 64
Else: MsgBox "服务器连接失败", 16
End If
USESQL ("select useid,password from userInfo")
Do Until Rsbdata.EOF
If txtuid = Rsbdata.Fields(0).Value And txtpwd = Rsbdata.Fields(1).Value Then
MsgBox "连接成功", 64
frmLogin.Hide
ElseIf txtuid = "" Then
MsgBox "请输入用户名", 16
txtuid.SetFocus
ElseIf txtpwd = "" Then
MsgBox "请输入密码", 16
txtpwd.SetFocus
ElseIf txtuid = "" And txtpwd = "" Then
MsgBox "请输入用户名和密码", 16
txtuid.SetFocus
Else: MsgBox "用户名或密码错误", 16
txtuid.SetFocus
End If
Rsbdata.MoveNext
Loop
End Sub

这是我程序的LOGIN窗体 它作用是连接SQL和验证用户名和密码
ConnectSQL(IP地址)函数是连接SQL函数
编译运行 输入用户名密码后按OK后
提示连接成功
但用户名密码错误 。
想不通 SQL SERVER里有相关记录 连接正

Else: MsgBox "用户名或密码错误", 16
txtuid.SetFocus
Else后应该没:

如果还不行就改成
If txtuid = Rsbdata.Fields(0).Value And txtpwd = Rsbdata.Fields(1).Value Then
MsgBox "连接成功", 64
frmLogin.Hide
Else MsgBox "用户名或密码错误", 16
txtuid.SetFocus
End If
If txtuid = "" Then
MsgBox "请输入用户名", 16
txtuid.SetFocus
End If
If txtpwd = "" Then
MsgBox "请输入密码", 16
txtpwd.SetFocus
End If
If txtuid = "" And txtpwd = "" Then
MsgBox "请输入用户名和密码", 16
txtuid.SetFocus
End If
其他一样

USESQL ("select useid,password from userInfo")
这个是你的rs function吗?