I make a window for login in c# win.form. I connect it to my database sql to table named Table. When i press on the button login:
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-F3KNAHJ;Initial Catalog=Login;Integrated Security=True");
string query = "Select * from Table Where username='" + textBox1.Text.Trim() + "' and password='" + textBox2.Text.Trim()+"'";
SqlDataAdapter sda = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
sda.Fill(dt);
if(dt.Rows.Count==1)
{
main objmain = new main();
this.Hide();
objmain.Show();
}
else
{
MessageBox.Show("Check your username or password");
}
i have : System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'Table'.'