SqlParameter已包含在另一个SqlParameterCollectiont中 [英] The SqlParameter is already contained by another SqlParameterCollectiont

查看:351
本文介绍了SqlParameter已包含在另一个SqlParameterCollectiont中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序调试时间发生以下错误。我该如何解决这个问题?



 



< pre lang =C#>另一个SqlParameterCollection已经包含了SqlParameter

描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪 有关错误的更多信息,其中源自代码中的关键字>。

异常详细信息:System.ArgumentException:另一个SqlParameterCollection已经包含SqlParameter

来源错误:


21 :SqlParameter [] parameter = ;
22 :parameter = new [] { new SqlParameter( ExamId,ExamId)};
23 return new eSoftExam()。GetQueryContext()。ExecuteStoreQuery< ExamDetails>( EXEC [dbo] .spEX_GetExamDetailss @ExamId,参数).FirstOrDefault();
24
25 :}

解决方案

首先清除参数。



例如:





 command.Parameters.Clear(); 


My application debugging time the following error occurs . How can i solve this?


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:         }

解决方案

First you clear the parameter.

For eg:


command.Parameters.Clear();


这篇关于SqlParameter已包含在另一个SqlParameterCollectiont中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆