Binding and saving DataGrid object with related DataTables fields

From: David K. (kerenshor_at_013.net)
Date: 03/25/05


Date: 25 Mar 2005 00:32:53 -0800

I am using C# .NET, and have 3 tables:
Customers, with the fields CustomerID (primary key), CustomerName.
Items, with the fields ItemID (primary key), ItemName.
Orders, with the fields CustomerID (primary and foreign keys), ItemID
(primary and foreign keys), Quantity.
The Customers and Orders Tables are one-to-many related by the
CustomerID field.
The Items and Orders Tables are one-to-many related by the ItemID
field.
I would like to bind the Orders table to a Windows Forms DataGrid, but
I would like that the CustomerName (from the Customers table) and the
ItemName (from the Items table) would be displayed in the DataGrid, as
well.
By the way, I already have another 2 DataGrids in order to maintain the
Customers and Items tables.
I would like that any change made to the DataGrid (either insert.
Delete or update) will effect the Orders table in the database.
My questions are:
1. How should I perform all the TableMappings?
2. Do I need 3 DataAdapters objects, or maybe 1 DataAdapters object
will do?
3. How should I bind the DataGrid?
Your help will be appreciated.

Thanks,
David



Relevant Pages

  • RE: Sync 3 related tables on a form
    ... You can try to maintain a multi query join string for the same purpose. ... Create a primary key in the Customers table. ... Create a relationship between the Orders table and the OrderDetails ...
    (microsoft.public.vb.database)
  • RE: How we get record from two database and insert into other database
    ... Create a primary key in the Customers table. ... Create a relationship between the Orders table and the OrderDetails ... The data type is string for this element, ...
    (microsoft.public.vb.database)
  • Re: Primary Key Dilemma
    ... > I'm designing an application that will be sold to multiple customers, each> of which is a small business. ... The database behind this application will be> accessed via the Internet, and will be shared by *all* customers. ... Each> business is permitted to access only its own data. ... It just doesn't seem right to me to have an auto inc column AND a> separate business_id column comprising the primary key. ...
    (microsoft.public.sqlserver.programming)
  • Re: Postpone creation of attributes until needed
    ... create table b, create pseudo column on table a, link to column on ... Assume a Customers table and an Invoices table. ... Users will never see the primary key, ...
    (comp.lang.python)
  • Re: Using DataAdapter.Fill()
    ... Here is the description from the documentation for AddWithKey: ... Adds the necessary columns and primary key information to complete the ... to put a 'distinct' in your query to retrieve each customer just once. ... Orders & Customers which are related by a CustomerID. ...
    (microsoft.public.dotnet.framework.adonet)