Click here to Skip to main content
14,733,542 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
dim ax(), be() as string



ax(i) = dr("EANAME").ToString()
be(i) = dr.GetString(1)



error is in line marked yellow error coding is



Object reference not set to an instance of an object.
Posted
Comments
   
Tag your language! Exception: 1st line or second, or some other?

"Solving the error" is the same as "cure the decease" or "feed the hunger".
--SA

Either dr is equal to Nothing or dr("EANAME") returns Nothing.

Check both condition in your code (or let exception go and handle it in appropriate place somewhere up the stack), but — more typically — make sure the variable is properly initialized. Returning of Nothing may or may not be used, it depends. If you use it, check it up in the caller.

This exception is one of the easiest to detect and fix in all programming; I don't know why so much buzz about it. Should you face a bug in dealing with Nothing, always run it under debugger and you will see everything.

—SA
   
Comments
asok6783 19-Aug-11 2:05am
   
dr("EANAME") has a value and it is written in a label but i am unable to store in an array
dim ax(), be() as string



ax(i) = dr("EANAME").ToString()
be(i) = dr.GetString(1).ToString()

Trythis.........
   

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