Reputation: 780
I am able to open the data grid connection , Now in data grid after opening i want to update particuar value through text box. But how should I update using grid.
Below is the code
private void button3_Click(object sender, EventArgs e)
{
SQLiteConnection connection4 = new SQLiteConnection(@"Data Source = C:\foo.sqlite;Version =3");
connection4.Open();
string sql2 = "Update Table set language1= '" + textBoxUpdate1.Text + "' where language1 = '" + textBox_Search.Text + "'";
SQLiteDataAdapter connect4 = new SQLiteDataAdapter(sql2, connection4);
DataSet ds4 = new DataSet();
connect4.Fill(ds4);
dataGridView.DataSource = ds4.Tables[0];
}
From the image i want to say that i want to update the language 2 , so i will type in the second text box where in the update statement i will set but "where" i want to choose where the user highlights in the data grid , below is the update table where datagrid selection is there , at that place i want data grid selected
like
string sql2 = "Update Table set language1= '" + textBoxUpdate1.Text + "' where language1 = '" + DATAGrid Selection + "'";
Is this possible?
Upvotes: 1
Views: 4740
Reputation: 780
Run the below code to edit particular thing from the grid. Just edit at the grid and press the update button. Form the below code you can edit the particular row by editing on it and press the update button
private void button3_Click(object sender, EventArgs e)
{
DataTable dt = dataGridView.DataSource as DataTable;
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i].RowState == DataRowState.Modified)
{
MessageBox.Show(dt.Rows[i][3].ToString());
}
}
Upvotes: 0