I am trying to create a log in screen for a WPF application. I was able to create the database and write code without any logical errors, however when I run the application it freezes. When I step through the program it freezes and tells me I have incorrect syntax adaptor.Fill(dataset, "0") at the closing parentheses.
Here is my code:
Imports System.Data
Imports System.Data.SqlClient
Class MainWindow
Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
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=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Members.mdf;Integrated Security=True"
command.CommandText = "SELECT * FROM (Users) WHERE Username = '" & nameButton.Text & "'AND Password= '" & pass.Text & "';"
connection.Open()
command.Connection = connection
adaptor.SelectCommand = command
adaptor.Fill(dataset, "0")
Dim count = dataset.Tables(0).Rows.Count
If count > 0 Then
Me.Hide()
Dim window1 As New Window1
Window1.Show()
Else
MsgBox("Incorrect Login please check user or psss", MsgBoxStyle.Critical)
nameButton.Clear()
pass.Clear()
End If
End Sub
End Class