Search code examples
c++c++builderadoconnection

Can't edit data in TADOTable


I made ​​the connection between C++Builder with access like this: ADOConnection> ADOTable> DataSource> DBGrid

I want to change the value of the current difficulties in this way ADOTable

enter image description here

void __fastcall TForm1::DBGrid1CellClick(TColumn *Column) {
int a, b;
a = ADOTable1->FieldByName("Value1")->AsInteger;
b = ADOTable1->FieldByName("Value2")->AsInteger;
ADOTable1->FieldByName("Total")->AsInteger = a + b;
}

When I run the above command directly in case of error.

I hope you understand what I say. because I do not speak English


Solution

  • Before setting field value you need to go into Insert, Append or Edit state:

    ADOTable1->Edit(); // edit the current record
    ADOTable1->FieldByName("Total")->AsInteger = a + b;
    ADOTable1->Post(); // save changes