|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to pass TableAdapater as parameterI 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. -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "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? > 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? > > > |
|||||||||||||||||||||||