Code:
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=.\SQLEXPRESS;CYRUS-PC\SQLEXPRESS\Databases\sample\Tables\dbo.Login=|DataDirectory|\DataBase.mdf;Integrated Security=True;User Instance=True") command.CommandText = "SELECT * FROM Login WHERE UserName='" & TextBox1.Text & "' AND Passwords='" & TextBox2.Text & "';" connection.Open() command.Connection = connection adaptor.selectCommand = command adaptor.Fill(dataset, "0") Dim count = dataset.Tables(0).Rows.Count If count > 0 Then MsgBox("Login Successfull", MsgBoxStyle.Information, "Login Passed") Else MsgBox("Invalid Account", MsgBoxStyle.Critical, "Login Failed") txtUsernameBox1.Clear() txtpassword.Clear() End If End Sub
Comment