Correct opening of dataset for update

Hello!
The situation:
Local(!!) Interbase database -> Dataset -> Datasource. My data is correctly being displayed in a DBGrid, but...as I am trying to update one specific grids column in all the selected rows of in the grid with a value retrieved from a treeview I am stuck!
The underlying Dataset returns an error: "Cannot perform this operation on a closed dataset" .

I am using this dataset to perform the select query that fills my DBGrid. Afterwards (at least I have thought it this way) I want to use the ModifySQL Property to fill in the Update statement and Execulte the SQL. But when I am trying to position the pointer to the bookmark of the actual cell (of of the SelectedRows) I get the error. (above)
Please help me! How can I solve this problem???

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
AnsiString treeViewCuenta = TV_cuentas->Selections[0]->Text;

	TBookmark TempBookmark;
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 ";
		DBG_cuentasComp->DataSource->DataSet->GotoBookmark(DBG_cuentasComp->SelectedRows->Items[i]);

		datamodule->IBDSet_cuentasComp->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();
}	
Topic archived. No new replies allowed.