DataRelations

Roey

Well-known member
Joined
Oct 10, 2002
Messages
238
Location
Canada
Hi, cant get my dataRelations to work. I have an n-tier app with an application layer calling a dataset from the lower levels:

Dim objRoutingMaster As New elantis_BUS.BusRoutingMaster()
Dim objWorkCentre As New elantis_BUS.BusWorkCentre()
Dim dsReturn As New DataSet()

Sub 1

dsReturn = objRoutingMaster.All

Sub 2

dsReturn = objWorkCentre.All


Data Acces Layer 1

myOleDbDataAdapter.Fill(dsReturn, "Routings")

Data Access Layer 2

myOleDbDataAdapter.Fill(dsReturn, "WorkCentre")


Back at the presentation tier

Dim WorkCentre As New DataRelation("WorkCentre", Me.dsReturn.Tables("Routings").Columns("WCID"), Me.dsReturn.Tables("WorkCentre").Columns("WCID"))

dsRoutingMaster.Relations.Add(WorkCentre)


I am getting an error stating that the object reference is not set. It seems to me as that when I call the dataadapter for the second time instead of adding another table to the dataset, it is overwriting the complete dataset.

What am I doing wrong ????
 
as far as objRoutingMaster.All and objWorkCentre.All they need to return a datatable and then you can added it to the same dataset.
and then you can add it the following way:

Code:
dsReturn.Tables.Add(objRoutingMaster.All)
dsReturn.Tables.Add(objWorkCentre.All)

now if you cant modified the functions to return datatables you can do the following:

Code:
dsReturn.Tables.Add(objRoutingMaster.All.Tables(0))
dsReturn.Tables.Add(objWorkCentre.All.Tables(0))

or change the 0s for the table name

Best of Luck
 
Thanks for your help

I have to pass the data as I Dataset as I am using a dataadpater in the Data Access Layer.

Tried the following command:

Me.dsWorkCentre.Tables.Add(objWorkCentre.All.Tables("WorkCentre"))

and got the error message:

DataTable already belongs to another DataSet.
 
Back
Top