Merging data from 2 tables into one grid

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.
 
S

Sahil Malik

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top