Solved

Force write to database

Posted on 1998-11-10
11
217 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
Comment Utility
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
Comment Utility
hi agenthex,

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

meikl
0
 

Author Comment

by:agenthex
Comment Utility
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
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 2

Expert Comment

by:SupWang
Comment Utility
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
Comment Utility
hi supwang,

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

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
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
Comment Utility
How can I take a look to the compentsources?
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
hi supwang,

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

meikl
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Also set LOCALSHARE to true.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now