Dim query = From row As dbDataSet.conformalRow In dbDataSet.tables("conformal") _ Where Not Isdbnull(row.Cal) AndAlso tiCal_drop.Text = row.Cal _ AndAlso Not Isdbnull(row.Tran) AndAlso tiTrans_drop.Text = row.Tran _ AndAlso Not Isdbnull(row.barrel) _ Select row.barrelIf query.Count() > 0 Then tibarrel_txt.Text = query(0)
抛出运行时异常:System.Data.StrongTyPingException – 表’conformal’中列’桶’的值为dbnull.
如何重写我的查询/条件以按照我的意图工作?
解决方法 默认情况下,在强类型数据集中,如果字段为null,则属性会抛出该异常.您需要使用生成的Is [FIEld] Null方法:Dim query = From row As dbDataSet.conformalRow In dbDataSet.tables("conformal") _ Where Not row.IsCalNull() AndAlso tiCal_drop.Text = row.Cal _ AndAlso Not row.IsTranNull() AndAlso tiTrans_drop.Text = row.Tran _ AndAlso Not row.IsbarrelNull() _ Select row.barrelIf query.Count() > 0 Then tibarrel_txt.Text = query(0)
或者DaTarow.IsNull方法:
Dim query = From row As dbDataSet.conformalRow In dbDataSet.tables("conformal") _ Where Not row.IsNull("Cal") AndAlso tiCal_drop.Text = row.Cal _ AndAlso Not row.IsNull("Tran") AndAlso tiTrans_drop.Text = row.Tran _ AndAlso Not row.IsNull("barrel") _ Select row.barrelIf query.Count() > 0 Then tibarrel_txt.Text = query(0)总结
以上是内存溢出为你收集整理的vb.net – 使用LINQ过滤DBNull全部内容,希望文章能够帮你解决vb.net – 使用LINQ过滤DBNull所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)