ODBCdatabase Timeout does nothing

I fill a listbox with the available ODBC connections, and have the use select one. This works perfectly for connections that do not require a VPN. However if a VPN is not connected, XoJo will sit and spin forever,requiring me to kill the program. Here is my connect code:

dim DSN as string
// now just select an available DSN from the listbox using a for loop. This works fine.
// I’m now ready to connect to the ODBC database. If VPN’s are connected, this works fine. But if user forgets to connect VPN, or the database is not otherwise
// online, I need to timeout. Here is my code, taken directly from example code in documentation:

DSN = lbxODBClist.Cell( selrow, 0 ) // user selected a DSN from the list
DSN.Timeout = 30 // presumably, this should time out if DSN is not reachable
if DSN.Connect() = false then
MsgBox( "Could not connect to ODBC DSN " + DSN.DataSource + EndOfLine + DSN.ErrorMessage )
Return
end if

If the DSN is available, this works great. If the VPN is not connected, the remote DSN connection try will not timeout. My progress wheel just spins and spins until I have to kill the program. This used to work in RealStudio but doesn’t in Xojo.

Is this a known bug?

Is this with a specific ODBC driver?

Do you see a different behavior if you try setting the timeout using SetConnectionAttribute with something like this:

DSN.SetConnectionAttribute(ODBCConstant.SQL_LOGIN_TIMEOUT, 30)

Does this code show that the ODBC driver is actually using the new timeout:

Dim timeout As Integer timeout = DSN.GetConnectionAttribute(ODBCConstant.SQL_LOGIN_TIMEOUT).IntegerValue

[quote=93043:@Paul Lefebvre]Is this with a specific ODBC driver?

Do you see a different behavior if you try setting the timeout using SetConnectionAttribute with something like this:

DSN.SetConnectionAttribute(ODBCConstant.SQL_LOGIN_TIMEOUT, 30)

Does this code show that the ODBC driver is actually using the new timeout:

Dim timeout As Integer timeout = DSN.GetConnectionAttribute(ODBCConstant.SQL_LOGIN_TIMEOUT).IntegerValue[/quote]

Just tried this, timeout is allways returning zero (0) in RS2012r2.1, Xojo2013r2 and Xojo2014r1.1.

My test was on Windows 8.1 with an ODBC connection into an Excel table. Maybe not all databases support the timeout argument.

Thanks for responding. The database itself is a remote PostgreSQL database that requires VPN for access. I was testing to see if the connection failure (I had the VPN off) would be caught by the timeout property. It did not.

I tried again with the SQL_LOGIN_TIMEOUT with the same effect. It did not stop after 30 seconds.

I’ve decided to use a timer and abort the connection event that way.

PS:
Connections to my SQL Server hosted by IX Webhosting with IP approval works just fine. I can also connect to PostgreSQL if turn the VPN on. So apparently the timeout settings are ignored.

For me today with ODBCDatabase to FileMaker, the timeout property does not work.
Any solution?

Confirm that neither the dc.timeout(n) nor SetConnectionAttribute(ODBCConstant.SQL_LOGIN_TIMEOUT, n) are working. Using Mac with 2015r2.1 connecting to SQL Server using Actual ODBC.

I’d like to implement that. Can you explain a bit?


Update: The timeout is honoured in a remote debug session on a Win7 VM.