Private Sub login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login.Click
Try
Dim con As New SqlConnection("Data Source=SUSHANT-PC;Initial Catalog=USB_APP;Integrated Security=True")
con.Open()
Dim cmd As New SqlCommand("SELECT username, password FROM admin WHERE (username = '" & username.Text & "') AND (password = '" & password.Text & "')", con)
Dim sdr As SqlDataReader = cmd.ExecuteReader()
' If the record can be queried, it means passing verification, then open another form.
If (sdr.Read() = True) Then
MessageBox.Show("The user is valid!")
Form2.Show()
Me.Hide()
Else
MessageBox.Show("Invalid username or password!")
End If
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class