Errors with sql and vb RRS feed

  • Question

  • Im making a login form and it pretty much working but for some reason only one password works is anything wrong here , i just get the error that its an invalid column name

    Imports System.Data.SqlClient

    Public Class LoginForm

        Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
            Dim connection As New SqlConnection
            Dim command As New SqlClient.SqlCommand
            Dim adapter As New SqlClient.SqlDataAdapter
            Dim Dataset As New DataSet

            connection.ConnectionString = ("Data Source=(LocalDB)\v11.0;AttachDbFilename= C:\Users\Nyasha\Documents\Visual Studio 2012\Projects\WindowsApplication5\WindowsApplication5\Students.mdf; Integrated Security=True")
            command.CommandText = "SELECT * FROM [Table] WHERE Username=  '" & txtUsername.Text & "'AND Password= " & txtPassword.Text

            command.Connection = connection
            adapter.SelectCommand = command
            adapter.Fill(Dataset, "0")

            Dim count = Dataset.Tables(0).Rows.Count

            If count > 0 Then


            End If

        End Sub
    End Class

    Sunday, January 10, 2016 12:40 PM