DataColumn array issue

  • Thread starter Thread starter Dave Powlin
  • Start date Start date
D

Dave Powlin

This code should work, but does not:

' create data relationship

Dim parentCol() As DataColumn
Dim childCol() As DataColumn
Dim dr As DataRelation

' I get an error message that Object Ref is not set
' the MSDN sample does it this way
'
parentCol(0) = ds.Tables(0).Columns("time_period_id")
parentCol(1) = ds.Tables(0).Columns("irx_network_desc")
childCol(0) = ds.Tables(1).Columns("time_period_id")
childCol(1) = ds.Tables(1).Columns("irx_network_desc")

' so I tried this and got the same message
'
' parentCol(0) = New
DataColumn(ds.Tables(0).Columns("time_period_id").ToString
' parentCol(1) = New
DataColumn(ds.Tables(0).Columns("irx_network_desc").ToString)
' childCol(0) = New
DataColumn(ds.Tables(1).Columns("time_period_id").ToString)
' childCol(1) = New
DataColumn(ds.Tables(1).Columns("irx_network_desc").ToString)

---------------------

What could I possibly be missing? The DataColumn array are not
instantiating.

Any ideas?

DP
 
You didn't give the arrays an initial size, so the array variable is just a
variable that is capable of pointing to an array of data columns. It isn't
actually pointing to such an array, it's pointing to nothing. And you can't
set the x'th element of an array, if there isn't an array there.
 
Back
Top