I am trying to make a windows form application in C#. I was trying to delete a particular row in Gridview and push the changes into the database. This delete does remove the row. All I want to do is push this updated gridview into the database.
privatevoid dataGridView1_CellContentClick(object sender,DataGridViewCellEventArgs e){string ind = e.RowIndex.ToString();int myint =int.Parse(ind); dataGridView1.Rows.Remove(dataGridView1.Rows[myint]); }
This is my code for Displaying the Database.
using (SqlConnectionMyConn=newSqlConnection("Data Source=LENOVO\\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=SampleData")){string query ="SELECT * from dbo. userpass";SqlCommand cmd =newSqlCommand(query,MyConn);try{SqlDataAdapter sda =newSqlDataAdapter();
sda.SelectCommand= cmd;DataTable dbdataset =newDataTable();
sda.Fill(dbdataset);BindingSource bSource =newBindingSource();
bSource.DataSource= dbdataset;
dataGridView1.DataSource= bSource;
sda.Update(dbdataset);}catch{}}