In my Datasnap client application i use 1 TSQLConnection for my methods and ProviderConnection.Problems arise when the connection is lost.Both TSQLConnection.Connected and TSQLConnection.ConnectionState don't catch this. When my TSQLconnection is open but i lose internet connection, or the server stops.The Datasnap client application gives lots of errors. (Server Methods or ClientDatasets) I have created a function to manage my SQL connection for my server methods. but more problems arise when for example is close a ClientDataset that is connected through a TDSProviderConnection. Q: How do you manage your client application to safely catch any disconnects on the TSQLconnection.Q: How do you manage downtime, and what do you do with unsaved client state. Reconnection after downtime is not the problem. When calling a servermethod: This would throw exception.
So i write next Method to obtain the TSQLCONNECTION from my datamodule with dummy method.
I wrote the Method this way because only way to find out if connection is lost is through dummy method wich would throw same error... then i can query for reconnect or close program. Edit: ( I'm expecting some kind of general answer and guidelines, Do's and don't. Not a correction of my code, this is just to show what i am doing at the moment. ) | ||||
We struggled with the same issue -- how to detect when the connection is severed, and how to gracefully reconnect. Here's what we ended up doing, which has proven to be very successful for us. Our users connect to the DataSnap server to retrieve data and make changes. All record creates, updates and deletes are fed immediately to the database via the Since you can't detect when the client has been forcibly disconnected from the DataSnap server until you try to communicate with the server and find out that the connection has been severed, we added a Our global exception handler looks something like this:
The Because of the way we handle the sync with the db (via All of that answers your first question... Someday, we will implement an offline mode where the |