火碱的价格:VB中如何建立与ACCESS的密码验证

来源:百度文库 编辑:高校问答 时间:2024/04/29 01:21:10
在VB6.0中如何建立密码验证系统?
数据库使用access,有TextuserID,和Textpassword,两个文本框,要求输入密码和ID进行验证,否则msgbox提示错误.
我用ADODC已建立和access的链接,就是不知道如何去验证,请高手指点~

Dim rs As New ADODB.Recordset
dim cnn As New ADODB.Connection

Private Sub Command1_Click()
Dim strsql As String
Set rs = Nothing
Set cnn = Nothing
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\用户表.mdb;Persist Security Info=False"
cnn.Open

If Text1.Text = "" Then
MsgBox "请输入用户名!", vbCritical + vbOKOnly, "提示"
Text1.SetFocus
End If
strsql = "select*from users where username='" & Trim(Text1.Text) & "'"
rs.CursorLocation = adUseClient
rs.Open strsql, cnn, adOpenStatic, adLockOptimistic
If Text2.Text = rs.Fields("password") Then
MDIForm1.Show
Unload Me
Else
MsgBox ("用户名或者密码不正确!"), vbCritical + vbOKOnly, "提示"
End If
End Sub

够详细了吧,呵呵,给分吧