'Joined' DataTables (columns from more-than-one db table)

  • Thread starter Thread starter Steve Hiemstra
  • Start date Start date
S

Steve Hiemstra

Hi All,

I have to display columns from multiple database tables in a grid. I have
been able to 'query' back a single DataTable using a custom SELECT (so I
have this DataTable in a DataSet). The DataSet binds to the grid fine.

The problem is in the UPDATE. I would like to the use the
DataSet.Update( ), but because I have a 'composite' table (and ADO.NET
requires a DataTable for each corresponding DataTable in the database) I
would need to 'split' my DataTable into separate DataTables (split off the
'like' columns and preserve the 'state' of the data).

I noticed the Select( ) method in DataTable. Maybe I could use that.

Using a separate custom UPDATE SQL statement for each changed row seems the
worst case...

Any ideas?

SteveH
 
I recommend you bring back many Datatables (only the rows you need though)
and create DataRelations on the client.
 
I don't think the select can give you a subset of columns - just a subset of
rows.

If you are using a SqlCommandBuilder, as long as you are updating columns
for only one of the tables, you can modify the SQL query to only select
columns from that one table. Then, the SqlCommandBuilder will be able to
build the right update statement for that one table.
 
Back
Top