
Signature
Contact:
Bauman Moscow State Technical University
Russia, Moscow 105005
Tel: +7915-426-6272
ICQ: 160-223-078
YM: Chipheo2k
Hi,
> Hello!
> I have 2 tables: Products (ProductID, ProductName) and
[quoted text clipped - 6 lines]
> dg.DataSource = ds;
> dg.DataMember = "Inventory_View";
Some options:
1)
Don't load a view, instead load the Product table and Inventory table, add
the right relation and add an expression column, eg:
DataSet ds = ...contains loaded Inventory and Product table...;
ds.Relations.Add("relProdInv",
ds.Tables["Product"].Columns["ID"] /*PK*/,
ds.Tables["Inventory"].Columns["ProductID"] /*FK*/ );
ds.Tables["Inventory"].Columns.Add("ProductName", typeof(string),
"Parent(relProdInv).ProductName");
Then display the Inventory table, it will also show the ProductName, you
only need to update the Inventory table then. Note that in NET1.1 it's
possible the update (DataAdapter.Update) will fail if there are expression
columns, so you need to remove them before and re-add them afterwards, bit
annoying but it works.
2)
Use your Inventory_View and setup an appropriate UpdateCommand on the
Inventory_View DataAdapter which should only include fields from the
Inventory Table. If you have no idea how to do this, then use the designer
to setup an DataAdapter for the Inventory Table and have a look at the
designer generated code for the UpdateCommand.
If you have any problems, please mention what framework you're using 1.1 or
2.0 ?
HTH,
Greetings
> ...
> Now, user can enter Qty for every product on datagrid. After that, when
> user clicks on button Save, I must update the table Inventory. Pls help me
> to do this update.
> Thanks.
Duong Nguyen - 23 Sep 2006 20:03 GMT
Hi,
thanks for your help!
I want to ask you if I use typed DataSet, so I can add the relation by the
visual designer, but how can I add the expression column? Do I need add it
programmatically?

Signature
Contact:
Bauman Moscow State Technical University
Russia, Moscow 105005
Tel: +7915-426-6272
ICQ: 160-223-078
YM: Chipheo2k
> Hi,
>
[quoted text clipped - 47 lines]
>> me to do this update.
>> Thanks.
Bart Mermuys - 23 Sep 2006 21:49 GMT
Hi,
> Hi,
> thanks for your help!
> I want to ask you if I use typed DataSet, so I can add the relation by the
> visual designer,
Just to be clear, Products must be the parent and Inventory the child.
> but how can I add the expression column?
You still didn't mentioned if you're using NET1.1 or NET2.0, but i think
it's pretty much the same: select your table inside the visual designer,
then click on the empty row and start typing to add a column, then open
"Property Window" and set the expression.
HTH,
Greetings
> Do I need add it programmatically?
>
[quoted text clipped - 49 lines]
>>> me to do this update.
>>> Thanks.