- Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connection As New SqlClient.SqlConnection
Dim command As New SqlClient.SqlCommand
Dim adaptor As New SqlClient.SqlDataAdapter
Dim dataset As New DataSet
connection.ConnectionString = ("Data Source=FEF-IT-002\SQLEXPRESS;Initial Catalog=WCPS;Integrated Security=True")
command.CommandText = "SELECT * FROM [Users] WHERE Username= '" & TextBox1.Text & "'AND Password= '" & TextBox2.Text & "';"
connection.Open()
command.Connection = connection
Dim sdr As SqlClient.SqlDataReader = command.ExecuteReader()
' If the record can be queried, Pass verification and open another form.
If (sdr.Read() = True) Then
MDIParent1.Show()
Else
MsgBox("Incorrect username or password", MsgBoxStyle.Critical)
TextBox1.Clear()
TextBox2.Clear()
Me.Refresh()
End If
End Sub
Can anybody out help me?


