SQL Server Disconnect

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

SQL Server Disconnect

Post by wjm4 » Sat 06 May 2017 22:51

I am having problems with sql server disconnecting my application arbitrarily. Is there a way I can get the tunisession to detect the disconnection and automatically reconnect. It seems I don't know of a disconnection until another query is executed. I want to be able to automatically connect and re execute the current query.

wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

Re: SQL Server Disconnect

Post by wjm4 » Mon 08 May 2017 18:49

I have tried to set the session to disconectedMode = true and localFailover = true.
When I do the onconnectionlost event does not execute, instead the onsessionerror event is triggered. I was expecting the onconnectionlost event to be triggered. Is this normal behavior?

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: SQL Server Disconnect

Post by azyk » Thu 11 May 2017 13:21

Please specify what exact component you are using to connect to SQL Server because TUniConnection does not have the onsessionerror event.

The TUniConnection.OnConnectionLost event does not occur at the moment when a connection to SQL Server is lost. This event occurs when UniDAC refers to the server and by that time the connection will be already lost. To use OnConnectionLost set the TUniConnection.Options.LocalFailover property to True. See more details in the documentation: https://www.devart.com/unidac/docs/?dev ... ilover.htm

You can find a sample of using OnConnectionLost in the FailOver demo project located in the subfolder "Demos\Miscellaneous\FailOver\" relative to the path where you have installed UniDAC demo projects.

Post Reply