public void ExecStoredProc(string strprocName, SqlConnection sqlConnect, List<string> Paramvalues)
{
if (ConnectToDB() == true)
{
SqlCommand cmd = new SqlCommand(strprocName, sqlConnect);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = strprocName;
SqlParameter parameters = new SqlParameter();
parameters.Value = Paramvalues;
cmd.ExecuteNonQuery();
}
}
This code is giving an error when I am passing the name of the procedure login which has two parameters,user and pwd. Though I am using the list to add parameters but it not not passed to the SP. Showing error in the line cmd.ExecuteNonQuery();
While you are declaring a new SqlParameter object you are not actually associating that object with cmd. Adding the below should help: