» Mannaging SQLConnection / Datasnap through client-server disconnects
Mannaging SQLConnection / Datasnap through client-server disconnects
|December 12, 2012
Posted by forumadmin
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.
function TDMForm.DSConnection: TSQLConnection;
if assigned(MYTSQLCONNECTION) then begin
ReconnectForm.ShowModal; // has a reconnect button that tries to reconnect + shutdownbutton
if ReconnectForm.modalresult=mrOK then
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. )
More Related Questions
- IntraWeb / DataSnap? I'm a hobby programmer trying to build a client/server application suite, using Delphi XE.
I write stand-alone applications occasionally, for my personal use. The problem is I don't know […]
- Replacing ASTA as a middletier solution I'm currently using Delphi7 along with ASTA to handle my client server communications to an Advantage DB.
I'm moving to Rad Studio XE Enterprise and am looking to switch to a different […]
- What are the current choices for Delphi Web & Web Service Development I'm toying around with Delphi. Most of my desktop development is done in .Net, and embedded systems with C. I've done some web development in RoR & Python (Django, CherryPy) I am […]
- Opening TWebBrowser link in default browser My application displays a small banner loaded from the web in a TWebBrowser control. This banner is actually a HTML page including an image; when the users click the image it takes them to […]
- IExplorerBrowser Performance Problems in Delphi XE2 I'm trying to write a multi-panel, multi-tabbed file manager. I have been using IExplorerBrowser, but performance is terrible compared to Windows Explorer. Creating a single instance isn't […]
- How to open an URL with the default browser with FireMonkey cross-platform applications? Usually, I use: ShellExecute(0, 'OPEN', PChar(edtURL.Text), '', '', SW_SHOWNORMAL);
How can I have the same behaviour (opening a link in the default browser), on all platforms (Windows […]
- With FireMonkey and its cross-platforms, where should I store my application data? Usually, with Windows, I save my application's data in the user folder (%appdata%).
For that, I use the function ExpandEnvironmentStrings which is linked to Windows to get the folder I […]
- Memory leak in the Win64 Delphi RTL during thread shutdown? For a long time I’ve noticed that the Win64 version of my server application leak memory. While the Win32 version works fine with a relatively stable memory footprint, the memory used by […]
- Delphi XE2 VCL styles, updating caption blocks other controls invalidation Found a glitch with VCL styles: when you update the form caption, other controls previously redrawn within the same procedure don't get repainted, and you are forced to call Repaint, […]
- When should I open and close a connection to SQL Server I have a simple static class with a few methods in it. Each of those methods open a SqlConnection, query the database and close the connection. This way, I am sure that I always close the […]