Hello,
I am trying to get to work a local interbase SELECT-UPDATE connection. The problem is:
Componens: IBDatabase with its IBTransaction and a IBDataset(IBDSet_cuentasComp) and IBDatasource.I display the data in a DBGrid (DBG_cuentasComp) and one of the colums is empty (default). I am now trying to fill this empty column with an entry from a TreeView (treeViewCuenta). So far so good. As I am now iterating through the selected cells of the DBGrid to fill these with the value I am facing troubles. It says "Cannot modify a read-only dataset". How do I manage the following procedure:
1. Loop through selected cells
2. Go to the selected cells record in the dataset
3. Fill the parameter of the ID of the actual row into the ModifySQL
4. Write the Treeview value into the cell (or is that done automaticaly after the UPDATE query and a refresh of the dataset?)
5. Save value and proceed to next selected line
Thank you very much for your time!! I am really stuck on this
My intent was the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
AnsiString treeViewCuenta = TV_cuentas->Selections[0]->Text;
TBookmark TempBookmark;
DBG_cuentasComp->DataSource->DataSet->DisableControls();
datamodule->IBDSet_cuentasComp->Edit(); => Throws error: "Cannot modify a read-only dataset"
TDataSetState status = datamodule->IBDSet_cuentasComp->State; // gives "browse" status if prior line is disactivated
for (int i = 0;i <= DBG_cuentasComp->SelectedRows->Count-1; i++){
TempBookmark = DBG_cuentasComp->DataSource->DataSet->GetBookmark();
datamodule->IBDSet_cuentasComp->ModifySQL->Text = "UPDATE \"cuentasSaldo\" CS SET CS.\"CSAL_CUENTACONAC\" = :cuentaConac WHERE CS.\"ID_CUENTASSALDO\" = :idCuentasSaldo ";
//datamodule->IBDSet_cuentasComp->GotoBookmark(TempBookmark);
DBG_cuentasComp->DataSource->DataSet->GotoBookmark(TempBookmark);
datamodule->IBDSet_cuentasComp->ParamByName("cuentaConac")->AsString = treeViewCuenta; datamodule->IBDSet_cuentasComp->ParamByName("idCuentasSaldo")->AsInteger = datamodule->IBDSet_cuentasComp->FieldByName("ID_CUENTASSALDO")->AsInteger;
datamodule->IBDSet_cuentasComp->ExecSQL();
// DBG_cuentasComp->DataSource->DataSet->FieldByName("CSAL_CUENTACONAC")->Text = treeViewCuenta;
}
|
What is the right dataset to use for "SELECT and UPDATE". Thanks