I'm trying to fill a class array with a DataSet that I retrieved from a table
If I populate a textbox directly from the DataSet it works perfectly, but population of the array gives me this exception, If arry(i).ArrID
is an Integer
system.NullReferenceException
The line is this:
arry(i).ArrID = ds.Tables(0).Rows(i).Item(0)
If arry(i).ArrID
is a string, the Exception reads
Object reference not set to an instance of an object.
I'm new to VB and would appreciate some help, thank you for your time.
In VBA, the Tables
object has a starting index of 1
, so if you're using an index of 0
, you're referencing a table that doesn't exist, hence the Null Reference. You should also change the Item(0) reference, and ensure i
is never set to 0
. [Source]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.