我的一个VB登录代码为什么写什么都会登录成功啊?求大神指导
vb吧
全部回复
仅看楼主
level 1
youlan001sdo 楼主
Dim Conn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim Comm As OleDbCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MessageBox.Show("请输入用户名!")
ElseIf TextBox2.Text = "" Then
MessageBox.Show("请输入密码!")
ElseIf TextBox1.Text <> "" Then
Try
Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=d:\zc.mdb")
Conn.Open()
Dim b As String = "Select * From 表1 Where 用户名 ='" & TextBox1.Text & "' and 密码 ='" & TextBox2.Text & "'"
Comm = New OleDbCommand(b, Conn)
Dim dr As OleDbDataReader
dr = Comm.ExecuteReader
MessageBox.Show("登录成功!")
查询.Show()
Catch
MessageBox.Show("登录失败!")
End Try
End If
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
2013年01月09日 10点01分 1
1