Click here to Skip to main content
15,910,872 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My application debugging time the following error occurs . How can i solve this?

C#


C#
The SqlParameter is already contained by another SqlParameterCollection.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: The SqlParameter is already contained by another SqlParameterCollection.

Source Error: 


Line 21:             SqlParameter[] parameter = null;
Line 22:             parameter = new[] { new SqlParameter("ExamId ", ExamId) };
Line 23:             return new eSoftExam().GetQueryContext().ExecuteStoreQuery<ExamDetails>("EXEC [dbo].spEX_GetExamDetailss @ExamId", parameter).FirstOrDefault();
Line 24: 
Line 25:         }
Posted
Updated 4-Dec-15 21:07pm
v2
Comments
phil.o 5-Dec-15 10:45am    
Is this code in a loop?

1 solution

First you clear the parameter.

For eg:


C#
command.Parameters.Clear();
 
Share this answer
 
Comments
ajeeshsathyan 5-Dec-15 3:37am    
SqlParameter[] parameter = null;
is for setting parameter null (clear)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900