DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

Got this Exception while calling DataAdapter.Update(MyDataTable);

reason: Forgot to fill the SourceColumn of the OdbcParameter.

Problem solved after setting SourceColumn like this:

_odbcDataAdapter.UpdateCommand = new OdbcCommand("UPDATE Tree SET SetId_Children = ? WHERE ([ID] = ?)");
_odbcDataAdapter.UpdateCommand.Connection = _odbcConnection;
OdbcParameter SetId_Children_Param = new OdbcParameter("SetId_Children", OdbcType.Int);
SetId_Children_Param.SourceColumn = "SetId_Children";
_odbcDataAdapter.UpdateCommand.Parameters.Add(SetId_Children_Param);
OdbcParameter IdParam = new OdbcParameter("ID", OdbcType.Int);
IdParam.SourceColumn = "ID";
IdParam.SourceVersion = DataRowVersion.Original;
_odbcDataAdapter.UpdateCommand.Parameters.Add(IdParam);

_odbcDataAdapter.Update(MyDataTable);

Figure 1. Sample Setting UpdateCommand and calling Update using ODBC.