i've been working with C# Application and i want to create login page for it but i face a problem with this code , it seemed to be not working
private void button1_Click(object sender, EventArgs e)
{
SqlDataReader sdr;
string query = "select * from User where User_Name = '" + textBox1.Text + "'and User_Password = '" + this.textBox2.Text + "'";
SqlConnection connectpassword = new SqlConnection(@"Data Source=AHMEDIBRAHIM\SQLEXPRESS;Initial Catalog=Payment;Integrated Security=True");
connectpassword.Open();
SqlCommand logincomand = new SqlCommand( query, connectpassword);
logincomand.Parameters.Add(@"n", SqlDbType.Text).Value = textBox1.Text;
logincomand.Parameters.Add(@"p", SqlDbType.Int).Value = textBox2.Text;
sdr = logincomand.ExecuteReader();
int i = 0;
while (sdr.Read()){
i = i + 1;
}
if (i == 1) {
MessageBox.Show("User Name and Password incroect ");
}
else if (i > 1)
{
MessageBox.Show("Duplicate username and password", "login page");
}
else
{
MessageBox.Show(" username and password incorrect", "login page");
}
Once i rung it ! .. i get this
Incorrect syntax near the keyword 'User'.