Parent\Child Form

SEF

Member
Joined
Feb 2, 2007
Messages
9
Programming Experience
Beginner
Hi as this is my first post, i will start by saying hello :)

I have a Database running on an SQL 2005 Server.

I am creating an App using Visual Studio 2005\Visual Basic.

I want to create a form where i enter orders and then enter the products and quanties for each order on a form.

I have a dataset with the orders table and the order details table, these are linked with the Primary key OrderID in the orders table and a OrderID foreign key in the order details table.

When i add Data to the form from the orders table in detail view and then add data from the orderdetails table in a data grid there seems no link between the two, they seem to work independently of each other, in the dataset designer the tables have the correct relationship and also on the Sql server side they have the correct relationship.

how do i get the order details grid to update when i create a new order.

Im new to VB.net, done alot of work in Access and VBA, but i think i might need code to do this?

Or is there a better way of doing this?

whats the norm for a order and order details scenario?

Any help would be appreciated

Many thanks
 
Hello Sef and welcome to the forums :)

If you search here for "Parent-Child data form" you will see lots of posts of what you are trying to achieve. This question is asked a lot on the forum :)

Basically your grid is not set to the relationship.

Is your relationship between the tables in SQL AND Visual Studio? You need the relationship to exist in Visual Studio.

If your relationship exists in VS:
click your "Data Sources" tab (normally found with Solution Explorer) and
expand your DataSet. You'll see your order table - expand this. You will now see at the bottom of the list for this dataTable your OrderDetail table - this is the relationship.
Drag and drop this table from the pane onto your datagrid on your form.

Run your app again and you will see your orderDetails related to the orders you are browsing through.

If you need the relationship
Double click your dataSet (.xsd) in Solution Explorer and create a relationship between your Parent table and Child table (click the Primary Key field in P and drag across to Foreign Key in C)

Hope that helps to get you started.
 
Parent\Child Problem Solved

Problem solved, i never knew that the orders table in the data source pane when expanded had the order details relation table within.

I have now dragged this onto the form as a data grid and everything is working fine.

I did search the forums and many others, found many things but maybe did not know how to word what i was looking for correctly.

Thanks for the help
 
yeah that's the major trouble - even I do it wrong at times.....you need to get the search wording right. Easiest thing is to search for minimal words, i.e.
"Child Relationship" or "Parent Child".

Glad to hear you got it sorted, good luck with your app(s) :D
 
Back
Top