解决并发冲突 执行用于在 Try...Catch 块中更新数据库的命令。 
如果引发异常,则检查 Catch 语句的 Row 属性,以确定导致冲突的原因。 
根据您的应用程序业务规则添加代码来解决错误。 
try
{
   SqlDataAdapter1.Update(myDataset);
}
catch (DBConcurrencyException ex)
{
   string customErrorMessage;
   customErrorMessage = "Concurrency violation\n";
   customErrorMessage += ex.Row[0].ToString();
   // Replace the above code with appropriate business logic 
   // to resolve the concurrency violation.
}

解决方案 »

  1.   

    你更新玩后调用一下dataset.acceptchanges()
      

  2.   

    你更新玩后调用一下dataset.acceptchanges()
    这个方法可以试试,因为我在做程序的时候也碰你上面的问题。
       acceptchanges()之后可以的。
      

  3.   

    决定用存储过程试试, access数据库能使用存储过程吗。
    还有如果我更新cDI_FileNameOld = @cDI_FileNameOld这个字段。无论我输入任何字符串,数据库存的都是0
    为什么
      

  4.   

    : Firestone2003(笨笨小猪) 
    我按照你的方法做了,现在报错是这样的。
    System.Data.OleDb.OleDbException: UPDATE 语句的语法错误。Line 385: try
    Line 386:            {
    Line 387:             dsCommand.Update(upLoadDV,UpLoadDVInfo_TABLE);
    Line 388:            }
    Line 389:             catch (DBConcurrencyException ex)
     
      

  5.   

    void MyDataGrid_Update(Object sender, DataGridCommandEventArgs e) 
          {
             // For bound columns, the edited value is stored in a TextBox.
             // The TextBox is the 0th element in the column's cell.
             TextBox oldFileNameText = (TextBox)e.Item.Cells[2].Controls[0];
             TextBox hbFileNameText = (TextBox)e.Item.Cells[4].Controls[0];
     
             String FilmName= e.Item.Cells[1].Text;  
             String oldFileName = oldFileNameText.Text;
             String hbFileName = hbFileNameText.Text;
            
     bool result;
             DataRow checkDataRow = checkDataTable.Rows[e.Item.ItemIndex];
     checkDataRow[upLoadDVData.cDI_FileNameOld_FIELD]=oldFileName;
     checkDataRow[upLoadDVData.cDI_ImageFileName_FIELD]=hbFileName;
    // Label1.Text=checkDataRow[upLoadDVData.iDI_ID_FIELD].ToString();
     result=upLoadDVData.UpdateUpLoadDV(checkDataSet);
     
             // With a database, use an update command to update the data. Because 
             // the data source in this example is an in-memory DataTable, delete the 
             // old row and replace it with a new one.
     if(result)
     {
             checkDataGrid.EditItemIndex = -1;
             BindGrid();
            }
    这是datagrid的update事件