System.NullReferenceException未处理。 [英] System.NullReferenceException was unhandled.

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

问题描述

我做了一个实例PersId得到我的数值(例如:1)

这是我的代码:



hi ,, i have made an instance PersId that gets i numeric value(Ex: 1)
and this is my code:

Dim dr3 As SqlDataReader
        dr3 = Personne.SelectPersId()
        If dr3.Read Then
            Dim PersId As Integer = dr3.GetValue(0)
           
            Me.A2BindingSource.Filter = "Client =" & PersId
            dr3.Close()
        End If





为什么它给我这个错误而且PersId(实例)= 1例如?



- >对象引用未设置为对象的实例



Why it gives me this error and PersId(the instance) is = 1 for example??

-->Object reference not set to an instance of an object

推荐答案

它完全取决于错误发生的位置:它发生在哪一行。 />


但最可能的问题是me.A2BindingSource为null(或 Nothing )而不是PersId。



在调试器中检查它,但由于读取器已读取一行,因此第一个元素不可能存在 - 因此最可能的来源是绑定源尚未设置。
It depends exactly where the error occurs: which line it is happening on.

But the most likely problem is that me.A2BindingSource is null (or Nothing) rather than PersId.

Check it in the debugger, but since the reader has read a row, it is unlikely to the the first element that does not exist - so the most likely source is the binding source not being set yet.


检查什么是PersId字段获取Null值..意思是如果你正在执行应用程序这个PersId doent获取值..以及它的主键字段..你知道吗主键字段va lue永远不会有空值..所以plz chk代码
Check whats is PersId fields obtaining Null value ..means if you are executing application this PersId doent getting value ..and if its primary key field ..you know that primary key field value never have null value ..so plz chk code


这篇关于System.NullReferenceException未处理。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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