Imports System.Data
Imports System.Data.SqlClient
Public Class FrmLogin
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New SqlConnection
Try
conn.ConnectionString = "data source='" & Me.TextBox1.Text & "';initial catalog=Supermarket;user id=text;password=text;"
conn.Open()
Dim sql As String
sql = "select * from employees where turename='" & Me.TextBox2.Text & "' and password='" & Me.TextBox3.Text & "'" & " and qxbs=1"
Dim cmd As New SqlCommand(sql, conn)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
If dr.Read = True Then
hh = True
Me.Close()
Else
MsgBox("用户名或密码错误!")
Me.TextBox3.Text = ""
End If
Catch ex As Exception
MsgBox(ex.ToString)
MsgBox("程序出错")
Finally
conn.Close()
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class