I have a subroutine which reads data from a datatable. When I call the subroutine from my button click event subroutine I get Object reference not set to an instance of an object.

It works when I call it from the load event subroutine. It must be because the Dim dt as New Datatable is in this subroutine.

I have tried moving Dim dt as New Datatable outside of the subroutines and I have tried adding the datatable as a parameter in the click event subroutine to no avail.

What to do? I can post the code if that will help.