能验证账号不能验证密码。。。求大神看看
Public Class Form1Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.MaxLength = 24
TextBox2.MaxLength = 24
TextBox2.PasswordChar = "*"
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("用户名不能为空!!请输入用户名!", 16, "错误!")
Exit Sub
End If
If TextBox2.Text = "" Then
MsgBox("用户密码不能为空!!请输入用户密码!", 16, "错误!")
Exit Sub
End If
Dim myconn As New OleDb.OleDbConnection
myconn.ConnectionString = "Provider=Microsoft.ace.OLEDB.12.0;Data Source=C:\Users\Administrator\Documents\账号密码.accdb "
myconn.Open()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter("select * from [表1]", myconn)
myconn.Close()
da.Fill(ds, "[表1]")
If ds.Tables(0).Rows.Count <> 0 Then
Dim sql As String = "select * from [表1] where UserID='" & TextBox1.Text.Trim() & "' "
Dim da1 As New OleDb.OleDbDataAdapter(sql, myconn)
Dim ds1 As New DataSet
da1.Fill(ds1, "[表1]")
If ds1.Tables(0).Rows.Count = 0 Then
MsgBox("用户名错误!")
TextBox1.Text = ""
TextBox1.Focus()
End If
Else
Dim sq2 As String = "select * from [表1] where UserID='" & TextBox1.Text.Trim() & "' and UserPassword ='" & TextBox2.Text.Trim() & "'"
Dim da2 As New OleDb.OleDbDataAdapter(sq2, myconn)
Dim ds2 As New DataSet
da2.Fill(ds2, "[表1]")
If ds2.Tables(0).Rows.Count = 0 Then
MsgBox("密码错误!请重新输入密码!")
TextBox2.Text = ""
TextBox2.Focus()
End If
End If
End Sub
End Class
[ 本帖最后由 qaz15963 于 2014-11-10 23:49 编辑 ]