Master detai problem

I have a search combobox,  on a master detail form.

dataset 1 has two datatables and a relation linking them through primary key and forigen key.

The parent in this relationship has a parameter in its Sql statement, it uses the selected value form the cocombox to fill the datatable, The problem is that the child table fills with all the record from its dataAdapter then it has an error,  "The dataset is violating the forign key constraint".  Im assuming this is because it is retreiving all the child records instead of just the ones for the parent.

Help!  Do i need to set the child with a parameter two?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you try passing "False" parameter when you create a datarelation? By default, ADO .NET enforces constraints.

something like

dr= New DataRelation("relationName", datacol1, datacol2, False)
Are you using one data adapter to fill both tables? If so, due to the way the select command works with the data adapter, you should use TWO data adapters. One to fill the parent table, and the other to fill only the child table.

Another suggestion, if I may, is to fill both tables, the master and the details table first, and THEN add the relation object to the database. If there is no exception when the relation is added to the dataset, then that's gravy. If not, then there is something wrong with teh select statement, and I would suggest verifying that the WHERE clause is selective enough for the pk fk constraint.

If you get this far, then

1. Bind the master grid 's datasource to the dataset, and the datamember to the name of the table.

2. Bind the details grid's datasource to the dataset, and the datamember to the name of the relation object.

Here is an MSDN article about this Master Details fun for your reference:

Good luck with your project.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.