有网友回馈说提供的代码有bug。你可以从这个链接下载得到:http://www.cnblogs.com/insus/p/3384472.html 其中有一个Utility,它是把DataTable转换为List<T>的方法:
反射(Reflection)的SetValue遇上DBNULL转换为string

问题发生在当DataTable字段中有值为NULL时,它会出现异常 》

Object of type 'System.DBNull' cannot be converted to type 'System.String'.

反射(Reflection)的SetValue遇上DBNULL转换为string

 

异常语句在#27代码。现Insus.NET把它稍作修改:
反射(Reflection)的SetValue遇上DBNULL转换为string

 

相关文章:

  • 2021-06-27
  • 2021-05-15
  • 2021-11-18
  • 2021-07-22
  • 2022-02-09
  • 2021-09-10
  • 2021-08-16
  • 2021-10-17
猜你喜欢
  • 2021-10-13
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-12-22
相关资源
相似解决方案