[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Master detai problem

Posted on 2004-11-05
3
Medium Priority
?
277 Views
Last Modified: 2010-04-23
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?

Nerdy_Girl.
0
Comment
Question by:Nerdy_Girl88
  • 2
3 Comments
 
LVL 2

Expert Comment

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

0
 
LVL 2

Expert Comment

by:karthikeyanTP
ID: 12512043
something like

dr= New DataRelation("relationName", datacol1, datacol2, False)
0
 
LVL 8

Accepted Solution

by:
gregasm earned 1500 total points
ID: 12515476
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:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingmasterdetailslistwithdatagrid.asp

Good luck with your project.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question