DataRelation Woes!!! Need Help (column argument cannot be null)

  • Thread starter Thread starter Hexman
  • Start date Start date
H

Hexman

Hello All,

I'm just trying to create a DataRelation in code on the fly. Come up with error "System.ArgumentNullException was unhandled
Message="'column' argument cannot be null. Parameter name: column" ParamName="column"". And I can't figure it out.

It appears that there is a parameter named "column", but I don't see where it is defined.

I have created all database items (tables, adapters, commandbuilders, etc) in code. I can access all datatables and everything appears as it should.
Its only when I attempt to create a datarelation as shown in the code below does it fail. It fails on the "Dim DataRelSSPP As ......" line.

I've looked at some online examples, looked in ADO.NET 2.0 Step by Step but to no avail. In fact most of the code below was copied from the internet.

I'm using VB Net 2005, Oledb/Access 2000.

What am I missing???


Thanks,

Hexman

============== Code Below ===================
Private Sub CreateRelation()

Dim dsWork As DataSet = New DataSet

SSCount = daSS.Fill(dtSS)
dsWork.Tables.Add("dtSS")

PPCount = daPP.Fill(dtPP)
dsWork.Tables.Add("dtPP")

Dim parentColumns() As DataColumn = New DataColumn() _
{dsWork.Tables("dtSS").Columns("SSDate"), _
dsWork.Tables("dtSS").Columns("SSItem")}

Dim childColumns() As DataColumn = New DataColumn() _
{dsWork.Tables("dtPP").Columns("HODate"), _
dsWork.Tables("dtPP").Columns("HOItem")}

' Create DataRelation.
Dim DataRelSSPP As DataRelation = New DataRelation( _
"SSToPP", parentColumns, childColumns)

' Add the relation to the DataSet.
dsWork.Relations.Add(DataRelSSPP)
End Sub
 
Back
Top