Solved

Apply database update

Posted on 2001-08-07
12
160 Views
Last Modified: 2012-05-04
Hi,

I create a database and now my problem is when I do Post, it's not actually write to disk.

I want to make it write to disk directly without caching it. How ???

Now I have several TTable and TDataSource components bind to several tables. But I use one navigation and one TDatasource to be the main user control to control those tables. How can I create a single direct write (without caching it) in this navigation TDataSource ? or should I do it for each tables ?

Anyway I know about ApplyUpdates and CommitChange in TTable, is using this is the right way ? Since in Delphi help it said doing ApplyChange still doesn't write it to disk.

Please give me a simple sample on correcting this problem :) thanks
0
Comment
Question by:comicboy
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6362670
what about

ttable.flushbuffers?
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6362715
There is a difference between cached updates and transactions. It sounds to me like you want to perform a transaction.

Transactions...as you may know... do write directly to disk. There are three levels (Look for Database.Transisolation in the help files)
tiDirtyRead
tiReadCommited
tiRepeatableRead

These are set in the Database Component. It encapsulates every database connection in Delphi, thus if you set its transisolation property to one of the three transactions listed above you should be in business!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6362791
>Transactions...as you may know... do write directly to disk

really?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 21

Expert Comment

by:gemarti
ID: 6362912
What is your point? Educate me!
Perhaps my wording was poor.

 
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6362929
guessing comicboy is using paradox or dbase with bde

a transactionmode can there only be tiDirtyRead
and does nothing else as lock the records which may modified during the transaction, but written is then when the transaction is committed

and the modifications are also not written at once,
they are cached until the bde becomes idle also
they may cached also in the os-cache

the ttable.flushbuffers method forces the bde
to write the pending cachebuffers to disk

to ensure that the os-also do write its pending cache,
the table must be closed and reopened

meikl ;-)
0
 

Author Comment

by:comicboy
ID: 6365305
Well what kretzschmar says might be what I want to know, you're right that I'm using Paradox in BDE. But now it turns to be scary to know that to make sure it is saved I must close and reopen the table ? wow and so if I want to make sure each time a post really written I should close it and open it immediately after I post it ?

Well that's really a terrible way, but I will do that anyway, I'll test it tommorow... :)

For gemarti, I do read in help about Database component thingy before I post this in EE but I'm so sorry I didn't use it in my app. I'm really new to database programming and still very poor on using this or that and so I don't understand what to do with database component with my app. anyway... and the ultimate thing is I don't know about anything else in database except TTable and TDatasource. That is why in my other EE question MNasman teach me on using ADO or somekind like that but too bad I don't have time yet to do it since my current assignment is still too much...

thanks for gemarti and kretzschmar...
0
 

Expert Comment

by:faustomen
ID: 6365832
0
 

Expert Comment

by:faustomen
ID: 6365834
0
 

Expert Comment

by:faustomen
ID: 6365844
0
 

Expert Comment

by:faustomen
ID: 6365869
Hi,

I worked with Paradox in BDE for a long time and I also had this same problem for a long time, till I find the solution. There is a function called DbiSaveChanges that forces writes to disk. This function can be found in BDE's API help, not in Delphi's help. To use it, you can create a procedure called fDbiSaveChanges, for instance, like the code below.

procedure TForm1.fDbiSaveChanges(hTmpHandle:hDBICur);
begin
  Check(DbiSaveChanges(hTmpHandle));
end;

In order to this procedure works, you must include the units BDE and DBTables in the USES clause of the unit.

Then, after your Post calls, you must call fDbiSaveChanges, like this:

fDbiSaveChanges(TTable.Handle);

replacing TTable with the table you want.

That's all you need to do. Hope it works!
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6365915
flushbuffers calls exact this, faustomen
0
 

Author Comment

by:comicboy
ID: 6366894
Wow, you're all are experts, I'm just hear this things today about BDE from you all.

Anyway I've tried what kretzchmar said and it's working ok I even do Close and Open TTable each Post to make sure it written to disk.

But how am I measure it is success still not too obvious since what I do is I post then I press <Ctrl> <F2> in Delphi to make the program close immediately. Then I reopen it and well the record is there...

What exactly my problem with this is happen like this when I input so many data then the electricity power goes down my computer off then my data is lost. That is why I'm asking how to make sure each posting is written ASAP.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

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