0

I am trying to get Database Data to insert into List View

Error Code:

Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object. occurred

enter image description here

UPDATE 1:enter image description here

CodePlague
  • 89
  • 1
  • 10
  • 1
    please DON'T post code as images. Take the time to post your code as properly formatted text. – Jason May 18 '17 at 12:51

2 Answers2

1

Either shMsg or sqldb is null.

Bertus van Zyl
  • 582
  • 5
  • 17
1

Put a breakpoint on line shMsg = FindViewById<TextView> (Resource.Id.shMsg);Then check if your resource is filled, and if you step 1 execution further, if the variable shMsg has a value. Then proceed stepping until you realise which object has a null value.

The reason you get this exception is because you're trying to get a property of something that doesn't exist, because it's null.

If the sqldb variable is null, make sure you don't dispose of the connection to the database prematurely, which is a common mistake.

Glubus
  • 2,819
  • 1
  • 12
  • 26
  • The breakpoint at `shMsg = FindViewById (Resource.Id.shMsg);` is null from the beginning – CodePlague May 18 '17 at 12:15
  • Which value is null? When you hit the breakpoint, or when the exception is thrown, you can mouseover variables and check their values set. – Glubus May 18 '17 at 12:24