cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
Hi All
Suppose I have 17 different typed datatables, and they will all be updated by a single datagrid at some point (at different times) in order to update the database, I nee dto use one of the 17 typed tableadapters that pair with the datatables..
Now, my question is, can this be done programmatically?
Can i say something like:
I currentlky know of no way to do this, other than my current plan:
I create a tableadapter for each table at startup, just so i can fill the datatable with values. If I retain this in a hashtable or colelction keyed by the datatable name, then i can look it up like:
AFAIK there is no direct link between datatables and their tableadapters, but if anyone knows if there is and how i can use it to retrieve the relevant table adapter for a given datatable, i'd love to know.
Thanks
**update:
I cant think of an easy way to do this - not by overloaded methods, nor hashtable storage - i cant treat a table adapter with sufficient genericity and all because there isnt a common base class for tableadapters that defines the ability to call an Update method. Am i going to have to write my own base and then when i do this, how to i write my method Update, so that the implementations in ym dataset override this method correctly? If they arent declared as override, i dont think i can slip into the hierarchy in the middle!
*thud*
Suppose I have 17 different typed datatables, and they will all be updated by a single datagrid at some point (at different times) in order to update the database, I nee dto use one of the 17 typed tableadapters that pair with the datatables..
Now, my question is, can this be done programmatically?
Can i say something like:
VB.NET:
Dim ta as TableAdapter
ta = DirectCast(myDataGrid.DataSource, DataTable).GetRelevantTableAdapter()
I currentlky know of no way to do this, other than my current plan:
I create a tableadapter for each table at startup, just so i can fill the datatable with values. If I retain this in a hashtable or colelction keyed by the datatable name, then i can look it up like:
VB.NET:
Dim ta as TableAdapter
ta = MyHashtable( DirectCast(myDataGrid.DataSource, DataTable).Name )
AFAIK there is no direct link between datatables and their tableadapters, but if anyone knows if there is and how i can use it to retrieve the relevant table adapter for a given datatable, i'd love to know.
Thanks
**update:
I cant think of an easy way to do this - not by overloaded methods, nor hashtable storage - i cant treat a table adapter with sufficient genericity and all because there isnt a common base class for tableadapters that defines the ability to call an Update method. Am i going to have to write my own base and then when i do this, how to i write my method Update, so that the implementations in ym dataset override this method correctly? If they arent declared as override, i dont think i can slip into the hierarchy in the middle!
*thud*
Last edited by a moderator: