TDAMemDataTable changed data not moved database

Hi, i’am in trouble again…

I have created ClientDataModule with DA wizard and there is three tables.

With two tables everything works ok with TStringGrid, can insert and edit records and they get updated to database. But with one table using TStringGrid, changes are added to TDAMemDataTable but after calling ApplyUpdates new and changed records are not updated to database.

Have added to TDAMemDataTables AfterApplyUpdates method ShowMessage(’’) and it shows, so ApplyUpdates() gets triggered.

Any idea where to start looking solution to problem?

EDIT: I can get Design-Time Data with no problems and when calling ApplyUpdates() method no errors are raised. New and edited data just don’t get updated to DB.

EDIT2: Just noticed that with new data added to TStringGrid TDAMemDataTables OnAfterPost event gets triggered when using TBindNavigators save button. But when pressing after that Refresh button at TBindNavigator, newly added record disappears from grid. So new record is not getting saved to TDAMemDataTable?

I tryed to add record in code to db:

begin
  ClientDataModule.tbl_asiakkaat.Edit;
  ClientDataModule.tbl_asiakkaat.Append;
  ClientDataModule.tbl_asiakkaat.FieldByName('nimi').AsString := 'abcd';
  ClientDataModule.tbl_asiakkaat.FieldByName('aktiivinen').AsString := 'efgh';
  ClientDataModule.tbl_asiakkaat.Post;
  ClientDataModule.tbl_asiakkaat.ApplyUpdates();
end;

In TStringGrid record shows after executing code but disappears after clicking TBindNavigator Refresh button. There’s AutoInc field in table and it’s value shows -1 as should. And record not gets inserted in to database.

I added manually second instance of TDAMemDataTable with same table and all started working. Checked settings from Wizard created components and didn’t find any differences. I added to to table more fields after wizard created DataModule and updated schema. maybe something didn’t get updated and caused problems? But now everything works as should.

Compare the DFM definition for both components and see.

No find when problem occurs, it happens when i add to database new column.

  1. Add new column to DB
  2. Update Schema with Relativity Server - Admin Tool
  3. TDAMemdataTable -> Retrieve Data table Schema

After these table.ApplyUpdate() don’t anymore save new/changed records to database.

If i add new TDAMemDataTable to Datamodule and set RemoteDataAdapter and LogicalName properties like they were original TDAMemDataTable, everything works again.

Checked from ClientDataModule.dfm and both original and new TDAMemDataTables are same.

Using FMX.

Previously after adding new column to database, have updated schema by deleting table and dragging table again to schema from connection manager. Or i have dragged table to schema not deleting table and when asked do i want to overwrite table, have selected yes.

Now i manually added new column to schema and everything seems to be working fine.

Sorry, have zero experience con relativity server.

Hi,

You can just clear fields in TDAMemDataTable and new fields information will be caught at opening table.

Thanks, use that next time.

Now just came new situation. Have added new field to database. But now when using mobile app what was compiled before updates to database schema, gives this error when it’s saving data to table where new fields are in database:

"Format of the data in the stream doesn’t match the destination table format.

The field isn’t found".

Mobile app does use table where new fields are, but it’s not using new fields at all.

Mobile app gets of course fixed when table fields are updated with new fields in datamodule and compiled again. But if i have 100 users using mobile app and i add new field to table at database, users apps raise exception when using table where new fields are. Is situation really so that when making changes to database, all apps need to be updated also? Or is this situation handled some other way?

Hi,

for such cases, you can just clear fields in run-time like

table.Fields.Clear;
table.Open;

this way is faster in comparing with 2nd way.

another way - update table schema with

table.LoadSchema(True,True);
table.Open;

last way may require additional call to server.

First problem seems to exist still.

Added to another table than when starting this discussion, new field. Added it to schema manually. After that table.ApplyUpdates didn’t post changes to DB from TDAMemTable.

Managed to fix problem by deleting TDAMemTable and adding new with same settings than deleted. After that posting updated/new records to DB with table.ApplyUpdates() worked again.

I’am making FMX app, is VCL version Delphi/DA more reliable?

Been playing with this and might be that problems are caused LiveBindings. Sometimes everything works and sometimes not, there’s no logic at all when things don’t work.

I got info from Delphi groups that LiveBindings is not stable, so move to use VCL in desktop apps and in Android do in code data related stuff.

usual TDBGrid shows all fields in table automatically. in FMX grid, it doesn’t work automatically.
as a result, after opening table, you need to manually create columns in grid and link them to fields…

Yes, thats what i have done. I have other troubles than this also, and they are caused by LiveBindings. I guess that DA has nothing to do with them. For example when compiling FMX app to Windows, all works. But when compiled to macOS, grids don’t show records. But records exist in TStringGrids, i handle record editing with second form what opens when double-clicked grid and that form shows first record of DataSet even it doesn’t show in grid.

Going to do more testing with TMS Grid, just downloaded it’s demo.