How to pass TableAdapater as parameter

  • Thread starter Thread starter ad
  • Start date Start date
A

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?
 
It is a Component derived class. The only way I see it is to pass a
Component and use reflection.
 
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.
 
Back
Top