关于Data Access Blok (SqlHelper.cs)使用时出现"对象必须实现 IConvertible/Object must implement IConvertible."异常

在使用低版本 Data Access Blok  时,出现如下异常
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

对象必须实现 IConvertible。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidCastException: 对象必须实现 IConvertible。

源错误:


行 360:   
行 361:   //finally, execute the command.
行 362:   int retval = cmd.ExecuteNonQuery();
行 363:   
行 364:   // detach the SqlParameters from the command object, so they can be used again.

参考http://weblogs.asp.net/ssmith/archive/2003/08/19/24524.aspx#92222
做修改
the simple fix is to change line 93 to read:
commandParameters[i].Value = ((SqlParameter)parameterValues[i]).Value;

instead of:
commandParameters[i].Value = parameterValues[i];

正常工作。

相关文章:

  • 2021-04-04
  • 2021-05-24
  • 2021-10-31
  • 2021-06-26
  • 2021-12-02
  • 2021-11-12
猜你喜欢
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-09-21
相关资源
相似解决方案