How can i update data from data grid view into SQL database using C#. Actually i m working on windows form app and i have to write update code in click event of the button.I am trying to update single row of data grid view into database. I have tried many sql queries for it but its not working :(
please help me :(
I have tried this code under a button like this
private void button9_Click(object sender, EventArgs e)
ds = new DataSet();
// 1. Create connection.
MySqlCommand cmd = con.CreateCommand();
// 2. init SqlDataAdapter with select command and connection
MySqlDataAdapter da = new MySqlDataAdapter("Select * from model", con);
// 3. fill in insert, update, and delete commands
MySqlCommandBuilder cmdBldr = new MySqlCommandBuilder(da);
dataGridView2.DataSource = ds;
//dataGridView2.DataMember = "Model";
*but when i change a record in the datagrid and press this button the datagrid becomes empty and nothing is updated to the database. please check it.