Roey Posted July 29, 2003 Posted July 29, 2003 Hi, can't 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 ???? Quote
karimgarza Posted July 29, 2003 Posted July 29, 2003 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: dsReturn.Tables.Add(objRoutingMaster.All) dsReturn.Tables.Add(objWorkCentre.All) now if you can't modified the functions to return datatables you can do the following: dsReturn.Tables.Add(objRoutingMaster.All.Tables(0)) dsReturn.Tables.Add(objWorkCentre.All.Tables(0)) or change the 0's for the table name Best of Luck Quote You're either a one or a zero. Alive or dead.
Roey Posted July 29, 2003 Author Posted July 29, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.