Forum > Databases

IBX : Can it handle database operation when network connection is not stable?

(1/9) > >>

incendio:
Hi guys,

I have this situations :

* Use IBX for database operations
* Use TIBDataset with CacheUpdate Enabled
I have an TDBEdit, with value = 'abc', then edit its value to 'abcde'

To Update database, I clicked Save button, which codes something like this

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.btnSaveClick(Sender: TObject);var  Tbl : array [1..1] of TDataSet; begin  Tbl[1] := Dt;  Dba.ApplyUpdates( Tbl);  ShowMessage('saved');end; 
That code works OK when network connection is OK, database value updated to 'abcde', but when network connection is lost, Dialog box showed with error message and option to click OK or Abort.
Error reading data from connection

That error was expected, if users click Abort, app closed, if user click OK, app not closed, value of TDBEdit in the screen still 'abcde'.

Problem is, when network connection restored again while app still open/ not restarted again, clicked again button Save still got same error like above.

Is IBX able to save data to the data  when network connection is restore again without need to restart the app?

MarkMLl:
I am not the best person to answer this, and hopefully somebody with specialist knowledge will come along shortly.

In general, I think you have to assume that the basic database components and underlying libraries require that a connection stays live. In addition, I think you should assume that the server is likely to abort a transaction if the connection goes down.

MarkMLl

korba812:

--- Quote from: incendio on November 24, 2021, 07:39:14 am ---Is IBX able to save data to the data  when network connection is restore again without need to restart the app?

--- End quote ---
I guess that's not possible. Queries linked to a dataset are prepared when the dataset is opened and are associated with the given connection.
If you cannot guarantee a permanent connection to the base, consider another solution, e.g. a web service or some RCP.

incendio:
That is too bad.

I have DevArt VCL for C++ builder that can handle database operation under unstable network.

I will ask them if their LCL for Lazarus also have the same features.

Zvoni:
a "manual" Workaround could be
1) Check Connected-Property before saving. If True everything OK, if False you have no Network.
2) If 1) is answered False, instead of "saving" implement a "queue" (Could be a StringList with the SQL-Statement).
You would also need a Procedure to try to reconnect back (own Thread?). TIBConnection's Ancestor TCustomConnection offers a published "AfterDisconnect"-Event. You could start the reconnect try from there. You would need a logic to exempt this code, if the User really wants to disconnect.
3) TIBConnection's Ancestor TCustomConnection offers a published "AfterConnect"-Event. If in 2) you reconnect successfully, "AfterConnect" should fire, and you could check if there are SQL-Statements waiting in the Queue

Navigation

[0] Message Index

[#] Next page

Go to full version