Solved

Force write to database

Posted on 1998-11-10
11
221 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 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