DataSet.Update on related tables.

  • Thread starter Thread starter Geir Holme
  • Start date Start date
G

Geir Holme

Hi all.
Could anyone help me with the following "common" chalenge?

I have 2 simple tables. Customers and Zipcodes.

Customer:
CustomerID, CustomerNr, CustomerName, ZipID

ZipCodes:
ZipID, ZipCode, ZipText

I use the ZipID in the Customer table so if it changes I can change it for
all Customers with that ID. Everey time I show this data in a grid I JOIN to
the ZipID and shows the ZipCode to the users. That works OK.

What I want to do i to use a dataset connected to a datagrid where the user
kan massupdate zipcodes. As you know the user don't know the ZipID that I
need to update the customer field with. He just want to change the ZipCode
on all the customers and push Update. I need to find the corresponding ZipID
and fill that into the corresponding Customer. Is there anyway this can be
incorporated into the dataset so I don't have to check and test and lookup
ZipID's. Mabe with some hidden columns or something.
Short Version:
When the user changes ZipCode in the datagrid I want to save the
corresponding ZipID on that Customer.

I would thing this scenario is rather common but....

I uses stored prosedures to fill and update all data in the database so I
guess I could handle it there based on the ZipCode, but if there are
anything within .NET that handles this I would like to use it.

Thanks a lott all.

-gh
 
Hi Geir,

Thank you for posting in the community!

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to do batch update with parent
and child tables. If there is any misunderstanding, please feel free to let
me know.

Generally, in this case, we often use a combo box to maintain the value of
the ZipCode or ZipText. When the text in the combobox changes, the value of
it changes too. Then we just update the data source with child
table(Customer table) directly.

Here is an technical artical in MSDN, which contains some sample code. I
think it might be useful to you.

http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx

HTH. Does this answer your question? If anything is unclear, please feel
free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin and thanks a lot!!

Yes, it is a batch update. Combo's are quite OK. I will have a look at
this this afternoon. Have to work too :-(

Yes, it is a batch update. Of course our customers want to update like
the do in XL!!

Wander if I can copy the same colums from XL into the datagrid and just
push insert....... Well I'll know tonight. Thanx again.

regards
geir
 
Hi Geir,

I'm not quite sure the meaning of XL in your last post. Do you mean by
Excel? If you mean copy and paste a column from Excel table to a DataGrid,
I think this cannot be achieved. DataGrid does not support this operation.
The sample on MSDN is quite good. It tells us how to create a column with
combo box in DataGrid and how to make that column display text on the
parent table.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top