If I bind a DataViewGrid
to a DataTable
, and change the data in the grid,
- How does the
DataTable
get notified of these changes? - Does the
DataTable
automatically update the DB? - If not, and I have to do it manually, how do I find out what the changes are?
- Does it make a difference if the
DataTable
was populated from aDataReader
or something else?
Or the "big picture" question:
Am I doing this all wrong? I have a database with one table, and I need to display this table and allow editing it. I don't have any fancy designers since this is a custom (not by me) database type and they only provideDataProvider
(is that what it is called?) classes like DataReader
, DataAdapter
, DataSet
, DataTable
, etc., but no design-time support. I am also glad for an opportunity to learn how to do all this in code and not with code-generators, but am getting very confused. Until 开发者_如何学编程now I always draged-and-dropped all my data needs, not even knowing if I was using readers or sets or whatever.
Thanks a lot.
BTW, are DataTable
s disconnected, that is in memory?
You have to use the DataAdapter and specify the Delete, Insert and Update commands. This is a decent explanation.
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/d402f6f4-52c6-48e3-88a6-4d6fbececf8a/
2 - No DataTable is disconnected, so you will need to get the changes back to the Database.
3 - DataTable.GetChanges()
精彩评论