System.NullReferenceException未处理。

编程入门 行业动态 更新时间:2024-10-26 04:29:12
本文介绍了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未处理。

本文发布于:2023-11-17 03:22:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未处理   System   NullReferenceException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!