Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
The SqlParameter is already contained by another SqlParamet
Krishna Kumar
Nov 12 2016 1:25 AM
742
Reply
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();
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
BadImageFormatException Error
I came up with requirement to print sequence of 3 numbers