DataColumn array issue

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
 
M

Marina

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top