问题描述
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickDimbAsIntegerDimdbConnectionAsOleDbConnection=NewOleDbConnection(dbcs)DimdataadapterAsNewOleDbDataAdapterDimdataset1AsNewDataSetdbConnection.Open()dataadapter.SelectCommand=NewOleDbCommand("select*fromme_singlefac",dbConnection)dataadapter.Fill(dataset1,"me_singlefac_bm")b=DataGrid1.CurrentCell.RowNumberDataGrid1.CurrentCell=NewDataGridCell(b+1,0)If(MsgBox("你确定修改记录?",4,"confirm")=MsgBoxResult.Yes)ThenDimoCommandBuilderAsOleDbCommandBuilder=NewOleDbCommandBuilder(dataadapter)dataadapter.Update(dataset1.Tables("me_singlefac_bm"))MsgBox("数据修改成功")EndIfEndSub在datagrid1中修改完数据,点按钮后datagrid中数据改变了,刷新datagrid1发现数据没有修改,access中数据也没有修改望高手赐教
解决方案
解决方案二:
同样的问题,期待~!
解决方案三:
我想你是没有绑定数据集的原因吧!我的写法如下,或许对你有帮助:DimcBuilderAsNewOleDbCommandBuilder(adapter)'创建一个CommandBuilder对象adapter.UpdateCommand=cBuilder.GetUpdateCommand'为数据适配器adapter的更新命令赋值adapter.Update(dSet,"R_RJG_DATA")'更新数据集dSet.Clear()'清空当前数据集adapter.Fill(dSet,"R_RJG_DATA")'重新绑定数据适配器dgdRejudgeHistory.SetDataBinding(dSet,"R_RJG_DATA")'在datagrid中显示更新后数据