Home All Groups Group Topic Archive Search About

Representing Related Data within a DataGrid

Author
17 Aug 2006 2:32 AM
Aaron
Hi,

It is possible to establish relationships between tables within a
dataset and this allows some useful features.  For example, given a row
from a table you can use GetParentRow, GetParentRows, GetChildRows.

However, I don't see a good way to represent data from multiple dataset
tables within a single datagrid (although I can think of at least one
bad way).  For example, if you have a Invoice table which instead of
having an company address, simply has a foreign key to an Address
table, but when the data is displayed in a grid, you want Invoice info
and the Address info to appear as 1 record.  In the examples that I
have read, if data from multiple tables is required in this way, the
data is actually obtained by giving the SelectCommand a query that
includes the proper SQL statement with joins, etc.  In this case, the
data from multiple tables is combined at the server and arrives within
the VB application as a single table.  While this is useful, I would
like to see if it is possible to combine data from multiple dataset
tables.

Since the dataset approximately represents a database, what I imagine
for the solution would be some way to generate a new dataview that
would aggregate the data together based on a SQL-like statement that I
passed to a dataset method.  This would also be different from writing
code that will generate a new combined table from scratch that if any
changes were made, the dataview would also be updated by changes in the
tables it was build from (I suppose you could also write code that
would update the generated table but would like to find a better way if
possible).

Also, I have noticed it is possible to set the datasource of a grid to
an entire dataset, but this does not produce the results I want.

Thank you,
Aaron

Author
17 Aug 2006 6:16 AM
Cor Ligthert [MVP]
Aaron,

It is possible, but don't expect to much from the result.

http://www.vb-tips.com/dbpages.aspx?ID=d55faa84-a853-4868-bdd8-ddebf666ce1e

I hope this helps,

Cor



Show quoteHide quote
"Aaron" <odysseus***@hotmail.com> schreef in bericht
news:1155781935.921511.3880@i42g2000cwa.googlegroups.com...
> Hi,
>
> It is possible to establish relationships between tables within a
> dataset and this allows some useful features.  For example, given a row
> from a table you can use GetParentRow, GetParentRows, GetChildRows.
>
> However, I don't see a good way to represent data from multiple dataset
> tables within a single datagrid (although I can think of at least one
> bad way).  For example, if you have a Invoice table which instead of
> having an company address, simply has a foreign key to an Address
> table, but when the data is displayed in a grid, you want Invoice info
> and the Address info to appear as 1 record.  In the examples that I
> have read, if data from multiple tables is required in this way, the
> data is actually obtained by giving the SelectCommand a query that
> includes the proper SQL statement with joins, etc.  In this case, the
> data from multiple tables is combined at the server and arrives within
> the VB application as a single table.  While this is useful, I would
> like to see if it is possible to combine data from multiple dataset
> tables.
>
> Since the dataset approximately represents a database, what I imagine
> for the solution would be some way to generate a new dataview that
> would aggregate the data together based on a SQL-like statement that I
> passed to a dataset method.  This would also be different from writing
> code that will generate a new combined table from scratch that if any
> changes were made, the dataview would also be updated by changes in the
> tables it was build from (I suppose you could also write code that
> would update the generated table but would like to find a better way if
> possible).
>
> Also, I have noticed it is possible to set the datasource of a grid to
> an entire dataset, but this does not produce the results I want.
>
> Thank you,
> Aaron
>
Author
17 Aug 2006 5:44 PM
Aaron
Cor,

Thank you for responding.  While setting a grid's datasource to a
dataset WILL allow a user to navigate the tables based on the
relationships, it does not have the capability that I was looking for.
Rather than showing the foreign key and clicking on a link to the
related data, I would like if the fk were not even shown to the user
the related data would appear in the same line of the grid.

I guess what I am looking for would be analogous to a SQL server View,
but instead of being created on the server, it would be created
entirely within the VB application with tables from a dataset.

Aaron
Author
17 Aug 2006 6:22 PM
Cor Ligthert [MVP]
Aaron,

The same as an advice I gave to somebody else yesterday, just use two grid
above each other, it is easier for you and your enduser. I did look as well
for what you are looking for, I never saw it.

If you need a link to our website where there are samples for that reply.

I hope this helps,

Cor
Show quoteHide quote
"Aaron" <odysseus***@hotmail.com> schreef in bericht
news:1155836674.641883.264890@i3g2000cwc.googlegroups.com...
> Cor,
>
> Thank you for responding.  While setting a grid's datasource to a
> dataset WILL allow a user to navigate the tables based on the
> relationships, it does not have the capability that I was looking for.
> Rather than showing the foreign key and clicking on a link to the
> related data, I would like if the fk were not even shown to the user
> the related data would appear in the same line of the grid.
>
> I guess what I am looking for would be analogous to a SQL server View,
> but instead of being created on the server, it would be created
> entirely within the VB application with tables from a dataset.
>
> Aaron
>