TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Krishna Kumar
NA
135
38.6k
The SqlParameter is already contained by another SqlParamet
Nov 12 2016 1:25 AM
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();
Reply
Answers (
8
)
BadImageFormatException Error
I came up with requirement to print sequence of 3 numbers