Hello...
i am passing the stored procedure name and parameter collection to this method. but while executing it is giving the error, The SqlParameter is already contained by another SqlParameter. eventhough i have added the parameters.clear() function to clear the parameters. but it is giving the same error
public void executeSP(string spname, SqlParameterCollection sp)
{
int retobj = 0;
//open connection
con.Open();
//execute SP
cmd = new SqlCommand(spname, con);
cmd.CommandType = CommandType.StoredProcedure;
if (sp.Count > 0)
{
foreach (SqlParameter p in sp)
{
cmd.Parameters.Add(p);
cmd.Parameters.Clear();
}
}
retobj=cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
//Close connection
con.Close();
Amit GuptaPosted Nov 14, 2016, 3:55 PM
parameters.Add(new SqlParameter("@Password", Password));
Krishna KumarPosted Nov 14, 2016, 9:56 AM
Amit GuptaPosted Nov 12, 2016, 12:14 PM
Pradeep SinghPosted Nov 12, 2016, 8:43 AM
Nitin SontakkePosted Nov 12, 2016, 4:50 AM
Amit GuptaPosted Nov 12, 2016, 4:15 AM
Krishna KumarPosted Nov 12, 2016, 2:16 AM
Nitin SontakkePosted Nov 12, 2016, 2:05 AM