I'm working on my app and I wanted to add a login system. When I input username and password into textboxes and press the button, the app closes. It's not even crashing (at least I would get an error list), it just closes the same way as if I clicked the close button.
I tried things from this post, but it didn't work at all.
Here is my code to connect to database and get username and password:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
MySqlConnection connection = new MySqlConnection("SERVER=localhost;DATABASE=userdata;UID=root;PASSWORD=root");
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MySqlCommand command = new MySqlCommand(
"Select userLogin, userPassword FROM users.userdata WHERE userLogin = '" + loginIn.Text +
"' AND userPassword = '" + passwordIn.Password + "'", connection);
connection.Open();
DataTable table = new DataTable();
table.Load(command.ExecuteReader());
}
}
Is my code wrong or it is some mysql issue because I'm confused.