VB.NET错误 [英] VB.NET ERROR

查看:75
本文介绍了VB.NET错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个错误"system.Null引用异常对象引用未设置为对象的实例".当我在带有null值的gridview中读取数据时

I get an error "system.Null reference exception object reference not set to an instance of an object" when i read data in a gridview with a null value

在下面找到代码

对于每行,作为Qualitix_POS.Form1.DataGridView1.Rows中的DataGridViewRow


                    ke.PrintRecItem(描述:= row.Cells("Column2").Value,价格:= row.Cells("Column4").Value,数量:= row.Cells("Column3").Value.ToString .PadRight(4,"0"), VatInfo:= row.Cells("Column6").Value,单价:= row.Cells("Column4").Value,UnitName:= row.Cells("Column1").Value)

                Next

For Each row As DataGridViewRow In Qualitix_POS.Form1.DataGridView1.Rows


                    ke.PrintRecItem(Description:=row.Cells("Column2").Value, Price:=row.Cells("Column4").Value, Quantity:=row.Cells("Column3").Value.ToString.PadRight(4, "0"), VatInfo:=row.Cells("Column6").Value, UnitPrice:=row.Cells("Column4").Value, UnitName:=row.Cells("Column1").Value)

                Next

推荐答案

您将需要在任何可能为null的单元格上使用断言.

You will need to use assertion on any cell that may be null.

例如,一种常见的方法是使用SomeCell.Value = DBNull.Value

For instance a common method is to use SomeCell.Value = DBNull.Value


这篇关于VB.NET错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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