So By Now I've Probably had little experience with Database Programming and just SQL in general, so if what I say is beyond confusing I Apologize. I've been trying to create a login form that accesses my database table and compare what the User has written to the table itself. After tirelessly searching the internet, I can't seem to understand why the Code I've written can't read the Table. here is an example maybe someone can help me understand my issue?
Public Function CompareDbValues(Compare_1 As String)
Using connection As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\OneDrive\Software\WindowsApplication1\WindowsApplication1\Database1.mdf;Integrated Security=True")
connection.Open()
Dim sSQL As String = "SELECT UserName, Password FROM [Table] WHERE UserName = 'Me.UserName.Text' AND Password = 'Me.Password.Text'"
Using Command As New SqlCommand(sSQL, connection)
Dim Reader As SqlDataReader
Reader = Command.ExecuteReader()
If Reader.HasRows Then
Do While Reader.Read()
If Compare_1 = Reader("UserName").ToString Then
Return True
Else
Return False
End If
Loop
End If
End Using
connection.Close()
End Using
Return False
End Function
My issue Seems to be when my code hits the "If Reader.HasRows Then" Line. Once again thanks for taking a look.