I have C# Window Forms project and MySQL ODBC connector to localhost server with all privileges. I also succeeded to fill dataGridView with data, but the changes I make are not stored back to the database. How do I creat开发者_运维问答e save button?
One easy, as in automagical, way to do it is to make a dataset: Menu>Data>Add New Data Source
When the wizard shows, choose Database, DataSet and choose new connection to connect to the database.
When you have the dataset in DataSource window move the dataset over a empty form and VS will create a number of buttons for you including a Save button.
When you have done that you can look at the code to see how it works and adapt that to your own need.
Good luck
edit
based on the comment you made to may answer I can guess that the database adapter you are using doesn't allow the generation of methods that talks directly to the database, hence the errrors dependency on the database connector. That is at least my understanding of this MSDN page
(See headline TableAdapter GenerateDbDirectMethods)
To resolve this you have to set the GenerateDbDirectMethods to false in TableAdapter and only use the InsertCommand, UpdateCommand, and DeleteCommand
精彩评论