Updating multiple source tables from a single datatable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H
I would like to select data from two (or more) source tables, and show the data in a grid where the data is in the same row of the grid. (Windows Forms

So, if we have a database with a company and an address table, like this
company: companyId, name, phone, fa
address: addressId, companyId, address, country, zipcod

The grid should have the fields from these two tables like this
Grid: name, phone, fax, address, country, zipcod

These fields should be in the same row, and the user should be able to edit and save changes

To get the data into one datatable, I made a query that joins the source tables and returns a datatable that is shown in the grid

The question I would like to ask is: "How do I update the source tables from this edited datatable

Thank you in advance
-Christian
 
The question I would like to ask is: "How do I update the source tables
from this edited datatable?

One way to do this is to call a customized stored procedure that accepts all
the fields to be updated as parameters and then update each table from this
parameters.

Ex:

CREATE PROCEDURE usp_Update
@p1 int,
@p2 int
AS
SET NOCOUNT ON
/* Insert update here for the first table for the @p1 parameter*/;
/* Insert update here for the second table for the @p2 parameter*/;


Christian said:
Hi
I would like to select data from two (or more) source tables, and show the
data in a grid where the data is in the same row of the grid. (Windows
Forms)
So, if we have a database with a company and an address table, like this:
company: companyId, name, phone, fax
address: addressId, companyId, address, country, zipcode

The grid should have the fields from these two tables like this:
Grid: name, phone, fax, address, country, zipcode

These fields should be in the same row, and the user should be able to edit and save changes.

To get the data into one datatable, I made a query that joins the source
tables and returns a datatable that is shown in the grid.
 
Thank you for your reply
Is it possible to do this without the use of Stored Procedures

Regards
Christian
 
Yes it is still possible. You just have to create a Sub that takes in the
parameters/fields that works like the stored proc I just mentioned.
 
Back
Top