FW_OpenAdoConnection reconnect

Post Reply
User avatar
cdmmaui
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
Contact:

FW_OpenAdoConnection reconnect

Post by cdmmaui »

Hello Everyone,

Is it possible to determine if FW_OpenAdoConnection is still alive before a FW_OpenRecordSet call and if it is NOT, is there a way to reestablish connection? Here is my sample code establishing connection.

oCn := FW_OpenAdoConnection( "MSSQL,"+xSOURCE+","+xDATABASE2+","+xUSERID+","+XPASSWORD, .T. )
if oCn == nil
? "Failed to connect to Server"
return nil
endif

Thank you!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: FW_OpenAdoConnection reconnect

Post by nageswaragunupudi »

Please check the value of oCn:State.
If the value is 0, the connection is closed. If the value >= 1 the connection is open and the actual value depends on the current activity.

If oCn is closed we can try reconnect by oCn:Open()

This is a sample code to check the connection status and try to reconnect.

Code: Select all | Expand

function Check( oCn )

   if oCn:State == 0
      TRY
         oCn:Open()
      CATCH
         ? "Can not reconnect"
      END
   endif
   
return ( oCn:State > 0 )
If still the connection can not be re-established, the possible reasons can be loss of internet connection, or physical network issues. This indicates the need for the user to physically remedy the situation and retry the operaration.
Regards

G. N. Rao.
Hyderabad, India
User avatar
cdmmaui
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
Contact:

Re: FW_OpenAdoConnection reconnect

Post by cdmmaui »

Thank you Rao
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: FW_OpenAdoConnection reconnect

Post by nageswaragunupudi »

Code: Select all | Expand

oCn := FW_OpenAdoConnection( "MSSQL,"+xSOURCE+","+xDATABASE2+","+xUSERID+","+XPASSWORD, .T. )
We can also write like this:

Code: Select all | Expand

oCn := FW_OpenAdoConnection( { "MSSQL", xSOURCE, xDATABASE2, xUSERID, XPASSWORD }, .T. )
Regards

G. N. Rao.
Hyderabad, India
User avatar
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: FW_OpenAdoConnection reconnect

Post by Maurizio »

Hello Rao
how to specify the port with FW_OpenAdoConnection() ?

Maurizio
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: FW_OpenAdoConnection reconnect

Post by nageswaragunupudi »

"ServerAddress:port"

eg:

Code: Select all | Expand

190.30.20.20:3306
Regards

G. N. Rao.
Hyderabad, India
User avatar
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: FW_OpenAdoConnection reconnect

Post by Maurizio »

Thank you Rao
Post Reply