Solved

Apply database update

Posted on 2001-08-07
12
154 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

12 Experts available now in Live!

Get 1:1 Help Now