Merging data from 2 tables into one grid

  • Thread starter Thread starter Raakeli
  • Start date Start date
R

Raakeli

I have a table with Project data on it.

Projects
--------
id
name
manager_id
budget
status

.... and a table with Employee data on it

Employee
--------
id
last_name
first_name
etc

I'm making a web service and would like to provide access (both read &
write) to the project information. I'd like the dataset to have
manager_id & his last & first name if the manager_id can be found on
the employee table (some projects are managed externally).

In the service, I tried using multiple tables in one dataset. Then, in
the application, I tried to bring the data from the 2 tables into one
grid, but I couldn't figure out how to do that.

I'd like the grid to have the following columns
Project.ID
Project.name
Project.manager_id
Employee.Last_name, Employee.First_name (of the manager)
Project.Budget
Project.Status

Seems like a simple thing to want, but so difficult to figure out how
to do it in dotnet.

Any help will be appreciated.
 
Raakeli,

To merge columns as you indicate below, the two datatables must have a
Unique constraint defined on the ID column. Once you have that defined on
atleast table1 (if your merge statement is table1.Merge(table2)) it will
produce a result as you want below.

Now did a DataTable have a merge method in 1.1? I'm not sure .. .. I don't
think it did .. so you're gonna have to use DataSet.Merge. But 2.0 has a
merge on the datatable ..

HTH

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
Back
Top