Solved

Force write to database

Posted on 1998-11-10
11
220 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:agenthex
11 Comments
 

Expert Comment

by:john_m
ID: 1346435
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346436
hi agenthex,

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

meikl
0
 

Author Comment

by:agenthex
ID: 1346437
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346438
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
 
LVL 2

Accepted Solution

by:
SupWang earned 50 total points
ID: 1346439
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
 
LVL 2

Expert Comment

by:SupWang
ID: 1346440
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346441
hi supwang,

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

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346442
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
 
LVL 2

Expert Comment

by:SupWang
ID: 1346443
How can I take a look to the compentsources?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346444
hi supwang,

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

meikl
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1346445
Also set LOCALSHARE to true.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question