Dim strConn
Private Sub cmdok_Click()
If Trim(TxtUserName.Text = "") Then
MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "提示"
TxtUserName.SetFocus
Else
If Trim(TxtUserPSW.Text = "") Then
MsgBox "请输入密码!", vbOKOnly + vbExclamation, "提示"
TxtUserPSW.SetFocus
Else
sn = TxtUserName.Text: sp = TxtUserPSW.Text
If (sn = "") Or (sp = "") Then Exit Sub
sql = "select * from psw where userName='" & sn & "' and userPSW='" & sp & "'"
Dim conn As New ADODB.Connection
conn.ConnectionString = strConn
Set rs = conn.Open(sql)
If rs.EOF Then
MsgBox "用户名或密码错误", vbOKOnly + vbExclamation, "提示"
Else
If Not rs("userPSW") = sp Then
MsgBox "用户名或密码错误", vbOKOnly + vbExclamation, "提示"
Else
'密码正确的代码
End If
End If
End If
End If
End Sub
Private Sub Form_Load()
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\test.mdb"
End Sub
运行后老实出现"缺少函数或变量"就是在Set rs = conn.open(sql) 这一行
帮我写个完整的代码啊,就通过数据库验证用户和密码正确则转到from2.show
[求助]老大们,一个个连接验证问题?