I'm getting error and I don't know what's wrong with the code, so If anyone can help me I would be grateful.
Error:
Incorrect syntax near ','.
and the highlighted line is
rdr = cmd.ExecuteReader();
Code:
cn.Open();
string query = "SELECT * FROM dbo.ispiti WHERE poID=@poID, sgID=@sgID, npID=@npID";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Parameters.AddWithValue("@poID", pr);
cmd.Parameters.AddWithValue("@sgID", pr1);
cmd.Parameters.AddWithValue("@npID", pr2);
SqlDataReader rdr;
try
{
rdr = cmd.ExecuteReader();
if (rdr.Read())
{
MessageBox.Show("Well done!");
}
}
catch(exception ex)
{
MessageBox.Show("Error!");
}
finally
{
cn.Close();
}
There is an error in your SQL statement. You should change
to