星空网 > 软件开发 > ASP.net

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

有网友回馈说提供的代码有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

 




原标题:反射(Reflection)的SetValue遇上DBNULL转换为string

关键词:string

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流