Home All Groups Group Topic Archive Search About

How to pass TableAdapater as parameter

Author
22 Apr 2006 8:25 AM
ad
I want to create a function which take a TablAdapter as parameter and return
a typed DataTable. Like:

DataTable GetDataTable(TableAdapter adp)
{
       .....
}

But I find there is no parent class for specific TableAdapter.

How can I finish this function?

Author
22 Apr 2006 6:51 PM
Miha Markic [MVP C#]
It is a Component derived class. The only way I see it is to pass a
Component and use reflection.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"ad" <fly***@wfes.tcc.edu.tw> wrote in message
news:Ob7KdZeZGHA.4936@TK2MSFTNGP05.phx.gbl...
>I want to create a function which take a TablAdapter as parameter and
>return a typed DataTable. Like:
>
> DataTable GetDataTable(TableAdapter adp)
> {
>       .....
> }
>
> But I find there is no parent class for specific TableAdapter.
>
> How can I finish this function?
>
Author
22 Apr 2006 6:59 PM
JohnMSyrasoft
Can you be more specific on what you're trying to do?

TableAdapters are defined against a strongly-typed dataTable and the queries
contained in a TableAdapter must match the schema of the typed DataTable.  I
don't think there is a way to generically pass a TableAdapter as a parameter.

Like DataAdapter, TableAdapter has both Fill and GetData methods builtin. 
For TableAdapters, GetData returns a new strongly-typed datatable.

MyTypedDataSetTableAdapters.Table1TableAdapter adp;
MyTypedDataSet.Table1DataTable tbl = adp.GetData();

There isn't a 'parent' or generic tableAdapter class that specific
TableAdapters inherit from.  Since a TableAdapter is like having a collection
of predefined parameterized queries that match a specifc table schema, I'm
trying to determine why you would want to pass it as a parameter to a
function that can only return a strongly-typed table.

Show quote
"ad" wrote:

> I want to create a function which take a TablAdapter as parameter and return
> a typed DataTable. Like:
>
> DataTable GetDataTable(TableAdapter adp)
> {
>        .....
> }
>
> But I find there is no parent class for specific TableAdapter.
>
> How can I finish this function?
>
>
>

AddThis Social Bookmark Button