Dave,
I've just been wrestling with the same issues (see my earlier post) -
so maybe this will ease your pain,
FWIW Table Adapters do not expose certain properties/events and it may
be better to use the old style DataAapter instead. AFAIK VS does not
provide a way to define RowUpdated events for the underlying Data
Adapter used by a Table adapter - you need to do this manually, but
the problem is that regenerating the Datasets etc can blow away any
changes you make.
(I too may be missing something here - but why are these nuances so
poorly documented (end of rant!) ).
David Sceppa describes the various alternatives (Data Adapters vs
Table Adapters etc) in his ADONET 2.0 book - highly recommended.
http://www.microsoft.com/mspress/books/5354.aspx
Here's another link that might shed some light:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=57791&SiteID=1
Hope this helps
Brendan
What do you mean "blow away my changes"? There is no need, the
strongly typed table adapter is a partial class so you can just add
your own .cs file and include any extensions you want. Then you can
regenerate the dataset at will, though you may have to fix any compile
errors of course. It's the nested-class structure of the DataSet which
can throw you.
public partial class MyDataSet {
////////////////////////////////////////////////
// DataSet level extensions.
////////////////////////////////////////////////
public void FillStuff() {
}
////////////////////////////////////////////////
// Table level extensions.
////////////////////////////////////////////////
public partial class YourTableDataTable {
// your code here
}
public partial class YourOtherTableDataTable {
// your code here
}
////////////////////////////////////////////////
// Row level extensions.
////////////////////////////////////////////////
[DebuggerDisplay("ID={YourTableId}, Name={Name}")]
public partial class YourTableRow {
// your code here
}
}
Of course you can split this out across multiple .cs files if you
want.
Note the use of the DebuggerDisplay attribute which I find helps a lot
during debugging.
Using the above technique you can create a public method to set the
connection used by a table adapter. You can also write public
transaction methods. Brian Noyes covers this in pages 61-65 of his
book "Data Binding with Windows Forms 2" by Brian Noyes.
Lastly, you can tame the nested types by using the "using alias"
feature liberally in your code, for example
using CountryTA =
Northwind.NorthwindTableAdapters.CountryTableAdapter;
using Countries = Northwind.NorthwindDataSet.CountryTable;
using Country = Northwind.NorthwindDataSet.CountryTableRow;
you can then write code like
foreach (Country c in myDS.Countries) {
...
}
I haven't really bothered with the events other than indirectly via
data binding so I can't comment on that. However you can drag "extra"
stuff out from the server explorer onto your data set. Try it and see.
Don't give up on typed data sets yet! I am finding them more and more
useful. It is well worth studying the generated code to find out what
it is doing. The above will make more sense then.
Hope this helps a bit,