joni
joni

Reputation: 43

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

Upvotes: 0

Views: 200

Answers (1)

Tracer
Tracer

Reputation: 2736

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

Upvotes: 1

Related Questions