First of all, this has nothing to do with WPF. Nothing at all. Moving on, you can add multiple parameters with a single statement, if you create a function to do that for you:
public void AddParameters(SqlCommand cmd, params SqlParameter[] parameters)
{
foreach (SqlParameter p in parameters)
{
cmd.Parameters.Add(p);
}
}
You can call that like this:
SqlCommand cmd = new SqlCommand("SELECT * FROM MyTable WHERE C1=@P1 AND C2=@P2");
AddParameters(cmd, new SqlParameter("P1", "..."), new SqlParameter("P2", "..."));
By using the
params
keyword, you can pass as many SQL parameters as you want to the function.