DataAdapter not filling Parent without Child

G

googlegroups

I have a dataset that is being filled from an Access DB. I have 2
tables which are a typical parent-child relationship. I defined the
relationship in Access to include all records from the parent and only
the child records that match the parent. In Visual Studio, I have 2
seperate DataAdapters. For some reason, it will only fill Parent rows
that have a corresponding child row. I have tried turning off
constraints on the dataset to no avail. Any other ideas?
 
J

John Saunders

I have a dataset that is being filled from an Access DB. I have 2
tables which are a typical parent-child relationship. I defined the
relationship in Access to include all records from the parent and only
the child records that match the parent. In Visual Studio, I have 2
seperate DataAdapters. For some reason, it will only fill Parent rows
that have a corresponding child row. I have tried turning off
constraints on the dataset to no avail. Any other ideas?

This probably has something to do with the way you wrote the code, so please
show us some of it. :)

In particular, it would be good to see the queries you're using.

John Saunders
 
W

W.G. Ryan eMVP

Assume that you have the following DataSet:

myDataSet - with two tables Parent and Child

Adapter1 has a Select command that will fill every row in the parent table
in Access

Adapter2 has a Select Command that will fill every matching child row

There is a datarelation between Parent and Child on SomeField but you've
disabled the constraints.

Now, you call Adapter1.Fill(myDataSet, "Parent");

and then you call Adapter2.Fill(myDataSet, "Child");

but the only records in Parent are ones that have matching child records
but there should be more?

If this is essentially the scenario, the problem is either that there aren't
Parent records in the Access DB that don't have matching child records or
that the Where clause in the Parent adapter's Select command is restricting
them out

To test it, just comment out the code that fills the child table- so only
the Parent is filled, then check the Rows.Count property. If it's > 0 then
it's pointing to the problem being the query or the data.
 

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