Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-10

Dataset modification and reading at the same time

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I am having a dilema with a dataset based app. I have 2 dataset objects pointing to the same database file, one connected with data-aware controls to allow the user to change the data and the other one only for reading. I need 2 because I need to show data based on the database while modifying it, and I can't iterate between items using the write dataset because that would disturb the user editing.

The problem now is that the write doesn't go immediately to disk, so when modifications are done this doesn't modify the displaying of data which is based on the read dataset.

Is it possible to have 2 dataset objects sharing the same memory database? Or else any ideas of how to solve this problem other then constantly writing changes to the disk and reloading the read dataset?

thanks,

Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 16 lines
Hello, I am having a dilema with a dataset based app. I have 2 dataset objects pointing to the same database file, one connected with data-aware controls to allow the user to change the data and the other one only for reading. I need 2 because I need to show data based on the database while modifying it, and I can't iterate between items using the write dataset because that would disturb the user editing. The problem now is that the write doesn't go immediately to disk, so when modifications are done this doesn't modify the displaying of data which is based on the read dataset. Is it possible to have 2 dataset objects sharing the same memory database? Or else any ideas of how to solve this problem other then constantly writing changes to the disk and reloading the read dataset?

It's not possible with SQL databases.

You can to it with objects, object persistence and mediators for data in-memory to the application (at least, I do :-) ).

If there are 2 apps then there is no way I know of to do what you ask.

Michael.

Reply by email

David Emerson
to Felipe Monteiro de Carvalho: I am having a dilema with a dataset based app. I have 2 dataset objects pointing to the…
Felipe Monteiro de Carvalho wrote
The problem now is that the write doesn't go immediately to disk, so when modifications are done this doesn't modify the displaying of data which is based on the read dataset.

Maybe you could do a sync operation or some such, to force changes to be written to disk. It would probably slow the system down, but you might be able to get it to work.

~David.

Reply by email

Luca Olivetti
to Felipe Monteiro de Carvalho: I am having a dilema with a dataset based app. I have 2 dataset objects pointing to the…

En/na Felipe Monteiro de Carvalho ha escrit:

The problem now is that the write doesn't go immediately to disk, so

How so? If you're using a database server (or sqlite), any connection should see the modifications as soon as the transaction is committed (in fact the data or the journal should be safe on disk).

when modifications are done this doesn't modify the displaying of data which is based on the read dataset.

You have to refresh it though.

Bye

Luca

Reply by email

Felipe Monteiro de Carvalho
to David Emerson: Maybe you could do a sync operation or some such, to force changes to be written to disk.…
David Emerson wrote
Maybe you could do a sync operation or some such, to force changes to be written to disk. It would probably slow the system down, but you might be able to get it to work.

Yes, but that's quite ineficient. I already have the data in memory, why write it to disk and read it again?

My current solution is setting TDataSource.Enabled to false before reading and store the current record and after finishing the read go to the original record and enable the data source. Controlling to read as few times as possible it doesn't interfere much with the user editing.

The whole problem is that I wish to have 2 current record pointers in the same database instead of only one, but that seams impossible with the current TSFDDataset. Maybe it's possible by extending it so that you can create a TSDFDataset which shares the memory of another already created one. If this second only does reading there should be no problem.

And while talking about TSDFDataset, would a property to decide if newly inserted records should go after of before the current record be welcomed? I like to use the standard navigation component and I find it very user unfriendly to have new records go before the current record.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Martin Schreiber
to Felipe Monteiro de Carvalho: I am having a dilema with a dataset based app. I have 2 dataset objects pointing to the…
Felipe Monteiro de Carvalho wrote 5 lines
Is it possible to have 2 dataset objects sharing the same memory database? Or else any ideas of how to solve this problem other then constantly writing changes to the disk and reloading the read dataset?
tmsebufdataset MSEgui trunk has the possibility to read dataset field values
by rowindex:
"
   procedure currentbeginupdate; virtual;
   procedure currentendupdate; virtual;
   function currentrecordhigh: integer; //calls checkbrowsemode
       //calls checkbrowsemode, writing for fkInternalCalc only,
       //aindex -1 -> current record
   procedure currentclear(const afield: tfield; aindex: integer);
   property currentisnull[const afield: tfield; aindex: integer]: boolean read
                 getcurrentisnull;
   property currentasboolean[const afield: tfield; aindex: integer]: boolean
                  read getcurrentasboolean write setcurrentasboolean;
   property currentasinteger[const afield: tfield; aindex: integer]: integer
                  read getcurrentasinteger write setcurrentasinteger;
   property currentaslargeint[const afield: tfield; aindex: integer]: int64
                  read getcurrentaslargeint write setcurrentaslargeint;
   property currentasfloat[const afield: tfield; aindex: integer]: double
                  read getcurrentasfloat write setcurrentasfloat;
   property currentasdatetime[const afield: tfield; aindex: integer]:
tdatetime
                  read getcurrentasdatetime write setcurrentasdatetime;
   property currentascurrency[const afield: tfield; aindex: integer]: currency
                  read getcurrentascurrency write setcurrentascurrency;
   property currentasmsestring[const afield: tfield; aindex: integer]:
msestring
                  read getcurrentasmsestring write setcurrentasmsestring;
"

Martin

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho: Yes, but that's quite ineficient. I already have the data in memory, why write it to disk…
Felipe Monteiro de Carvalho wrote 26 lines
On Mon, Oct 5, 2009 at 3:24 PM, David Emerson wrote: > Maybe you could do a sync operation or some such, to force changes to be > written to disk. It would probably slow the system down, but you might > be able to get it to work. Yes, but that's quite ineficient. I already have the data in memory, why write it to disk and read it again? My current solution is setting TDataSource.Enabled to false before reading and store the current record and after finishing the read go to the original record and enable the data source. Controlling to read as few times as possible it doesn't interfere much with the user editing. The whole problem is that I wish to have 2 current record pointers in the same database instead of only one, but that seams impossible with the current TSFDDataset. Maybe it's possible by extending it so that you can create a TSDFDataset which shares the memory of another already created one. If this second only does reading there should be no problem. And while talking about TSDFDataset, would a property to decide if newly inserted records should go after of before the current record be welcomed? I like to use the standard navigation component and I find it very user unfriendly to have new records go before the current record.

New records do Insert() and Insert goes before the current record so this is normal. It is like that in Delphi as wwell.

Do an Append() instead.

Michael.

Show quoted text 8 lines
thanks, -- Felipe Monteiro de Carvalho _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt

You are right, but what I want isn't append, I want to insert after the current record, not in the end of the dataset. It seams that what I need is a new button option to TDBNavigator, maybe nbInsertAfter.

Felipe Monteiro de Carvalho

Reply by email