我在DataGridView单元格数据改变时如何将更改返回数据库
数据填充方式如下
DataTable datatable = new DataTable();
SqlDataAdapter ada = new SqlDataAdapter(s,con);//S为查询条件字符串
ada.Fill(datatable);
dataGridView1.DataSource = datatable;
下面是我写的更改事件触发程序段,可以运行但是无法将更新提交数据库,请各位高手帮忙解决
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
string s = dataGridView1.CurrentRow.Cells[1].FormattedValue.ToString();
string s2 = "自编号='" + s + "'";
this.bV_车辆TableAdapter1.Update(this.busInfoSysDataSet.BV_车辆.Select(s2,null,DataViewRowState.ModifiedCurrent));
}
数据填充方式如下
DataTable datatable = new DataTable();
SqlDataAdapter ada = new SqlDataAdapter(s,con);//S为查询条件字符串
ada.Fill(datatable);
dataGridView1.DataSource = datatable;
下面是我写的更改事件触发程序段,可以运行但是无法将更新提交数据库,请各位高手帮忙解决
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
string s = dataGridView1.CurrentRow.Cells[1].FormattedValue.ToString();
string s2 = "自编号='" + s + "'";
this.bV_车辆TableAdapter1.Update(this.busInfoSysDataSet.BV_车辆.Select(s2,null,DataViewRowState.ModifiedCurrent));
}
Windows Forms涓帶浠剁粦瀹氭暟鎹簮鍚?
....DataBindings.add(binding("text",busdataset.B_Class,"value",true)
浠g爜鍙兘涓嶅噯纭紝涓嶈繃澶ф灏辨槸杩欐牱锛屽綋鎺т欢涓殑鏁版嵁涓夋洿鏀规椂濡備綍灏嗘暟鎹彁浜や細鏁版嵁搴?