C# version here.
VB.NET Code:
Dim connection As New SqlConnection("connection string here")
'Get the count of the records with matching user ID and password.
Dim command As New SqlCommand("SELECT COUNT(*) FROM User WHERE UserID = @UserID AND Password = @Password", _
connection)
'Add the parameters. Values might come from TextBoxes or wherever.
With command.Parameters
.AddWithValue("@UserID", userID)
.AddWithValue("@Password", password)
End With
connection.Open()
'Execute the query.
If CInt(command.ExecuteScalar()) = 0 Then
'Zero matching records means a failed login.
Else
'The specified credentials do match a record so the login succeeds.
End If
connection.Close()