I have a user defined object "shape_ref". The object corosponds to a table row, so that the various columns in the row are properties in the object.
I am trying to create a function that will return all rows as an object array:
dr = cmd.ExecuteReader();
{
sr[i].id =
sr[i].name = dr[
sr[i].description = dr[
sr[i].image = dr[
sr[i].dimCount =
sr[i].dim1Label = dr[
sr[i].dim2Label = dr[
sr[i].dim3Label = dr[
sr[i].dim4Label = dr[
sr[i].dim5Label = dr[
sr[i].dim6Label = dr[
i = i++;
}
The problem I am having is the first time I try to set the value:
sr[i].id = Convert.ToInt16(dr["sr_id"]);
I get an error: "Object reference not set to an instance of an object.", but from what I can see, the "sr[]" IS set using the New statement.
Anybody see what I'm doing wrong?