So, gaurav is somewhat right, but not in the right spot of your code. Your problem is actually that you dispose of getauditReasonDT.
Here's what happens in memory (as an example) with your code.
You create getauditReasonDT which creates a pointer.
Address | Type | Data |
0x1 | Pointer | Null |
You then set it to
New Table()
(which is total unnecessary since you later set it to something else.
Address | Type | Data |
0x1 | Pointer | 0x2 |
0x2 | DataTable | Blank DataTable |
Then, you pass getauditReasonDT back which is really only passing the location of the data in memory (so in this case, it's just passing
0x2
.
Then, you set dispose which disposes of the datatable in memory so those pointers have nowhere to point.
At least that's how I understand it.
And as far as I know, dispose of the DataAdapter doesn't dispose of the DataTable that it filled. I do this in my code all of the time and never have any problems.