Click here to Skip to main content
14,699,489 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
        End If

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

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

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.
[no name] 6-Sep-13 10:45am
yes, the error is in line of :
Me.A2BindingSource.Filter = "Client =" & PersId
but i'm sure that PersId has a value (1 or 2 for example)
how to fix it ??
OriginalGriff 6-Sep-13 11:03am
Read my solution: the bit where it says "Check it in the..."
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 know that primary key field value never have null value plz chk code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900