Force write to database

I save data in a paradox database using TTable. If the app crashes instead of normally shutting down, my changes to the database are lost. Is there any way to force the database files to update? Please don't respond with CommitUpdates or FlushBuffers. If you have an answer, test it to make sure it  works because I've tried alot of different methods and all failed.
agenthexAsked:
Who is Participating?
 
SupWangConnect With a Mentor Commented:
hi, agenthex

Add the BDE declared in your uses section. and use the function: DBISaveChanges(yourTable1.Handle); That will write the data to real the database.

regards,
SupWang
0
 
john_mCommented:
Note that you may have tried telling the BDE to save the buffers (something like DbiSaveChanges or something), but under certain operating systems, the process of writing any data to disk may be cached. This is especially the case with NT. Take a look at the Win32 API...


0
 
kretzschmarCommented:
hi agenthex,

the easiest way is to close and reopen your table, but it sucks perfomance.

meikl
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
agenthexAuthor Commented:
meikl,
   actually I already do close and reopen the TTable. It doesn't work :/ I'm thinking it may be the fault of the database-aware controls.

agenthex
0
 
kretzschmarCommented:
hi agenthex,

then i think john_m has right because OS has cached the information, and you must force the OS to write back on hd. If your table local or on a network?

meikl
0
 
SupWangCommented:
notice: the BDE declared will cause the Abort procedure could not be compile. The error message is : Statement expected, but expression of type 'Integer' found. (Delphi 3)
use SysUtils.Abort instead Abort.
0
 
kretzschmarCommented:
hi supwang,

you are fast with your answers, but see john_m comment.

meikl
0
 
kretzschmarCommented:
hi supwang, hi agenthex,

i have take a look to the compentsources(D3). the method flushbuffers use the dbisavechanges-function. so it seems dbisavechanges is not the solution for your problem. there is an win32 api call :

FlushFileBuffer(FileHandle)

FileHandle could be the tablehandle (not tested out yet)

meikl
0
 
SupWangCommented:
How can I take a look to the compentsources?
0
 
kretzschmarCommented:
hi supwang,

you must have the Delphi C/S Edition (all componentSources included)!

meikl
0
 
ronit051397Commented:
Also set LOCALSHARE to true.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.