DataView of a multiple tables? a la SQL view

J

Jiho Han

I have 3 sql tables which are related to one another and I am trying to
create a dataset that represents a subset of columns in those tables. In
other words, the dataset will have 3 DataTables and however many necessary
DataRelations that represent the connections among them. My question is
that is there a way to create a DataView that represent a single view from
all three tables, so that I can easily bind it to a datagrid for example?
It seems that DataView's constructor only takes a single DataTable. This is
puzzling and maybe I am incorrect to think that DataView is synonymous with
SQL views. As you know in sql you can create a view that selects from
multiple tables with whatever criteria you specify.

Thanks for your help.
Jiho
 
M

Miha Markic [MVP C#]

Hi again,

And here is the link to second example:
HOW TO: Implement a Custom DataView Class in Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;325682&Product=vbNET

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Miha Markic said:
Hi Jiho,

Yes, you are correct - DataView works only on one table.
There are couple of solutions though:
- one is to build join DataTable
see
HOW TO: Implement a DataSet JOIN helper class in Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;326080&Product=vcSnet

- other is to create a datasource class which wraps around involved tables

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Jiho Han said:
I have 3 sql tables which are related to one another and I am trying to
create a dataset that represents a subset of columns in those tables. In
other words, the dataset will have 3 DataTables and however many necessary
DataRelations that represent the connections among them. My question is
that is there a way to create a DataView that represent a single view from
all three tables, so that I can easily bind it to a datagrid for example?
It seems that DataView's constructor only takes a single DataTable.
This
is
puzzling and maybe I am incorrect to think that DataView is synonymous with
SQL views. As you know in sql you can create a view that selects from
multiple tables with whatever criteria you specify.

Thanks for your help.
Jiho
 
J

Jiho Han

Thanks Miha for your response.

I am at the moment in a crunch mode so I had to resort to xsl to create a
"joined" DataSource. But I will definitely visit your other options. I am
especially interested in DataSetHelper option.

Thanks so much!!!
Jiho

Miha Markic said:
Hi again,

And here is the link to second example:
HOW TO: Implement a Custom DataView Class in Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;325682&Product=vbNET

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Miha Markic said:
Hi Jiho,

Yes, you are correct - DataView works only on one table.
There are couple of solutions though:
- one is to build join DataTable
see
HOW TO: Implement a DataSet JOIN helper class in Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;326080&Product=vcSnet
- other is to create a datasource class which wraps around involved tables

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Jiho Han said:
I have 3 sql tables which are related to one another and I am trying to
create a dataset that represents a subset of columns in those tables. In
other words, the dataset will have 3 DataTables and however many necessary
DataRelations that represent the connections among them. My question is
that is there a way to create a DataView that represent a single view from
all three tables, so that I can easily bind it to a datagrid for example?
It seems that DataView's constructor only takes a single DataTable.
This
is
puzzling and maybe I am incorrect to think that DataView is synonymous with
SQL views. As you know in sql you can create a view that selects from
multiple tables with whatever criteria you specify.

Thanks for your help.
Jiho
 

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