Home All Groups Group Topic Archive Search About

ODBC ConnectionTimeout not working?

Author
5 Dec 2006 5:43 PM
Eve
If the user name or password is invalid as I'm attempting to make a
connection, I get the login window. The problem with that is when my
application runs as a service, the user can't really enter that information,
so I just want to set up a timeout and when the error gets generated, I want
to close the login window. Here's my code, but the timeout never occurs, what
am I doing wrong?

Try
  Dim cnOdbc As OdbcConnection
  cnOdbc = New OdbcConnection(strConnectionString)
  cnOdbc.ConnectionTimeout = 600
  cnOdbc.Open()
Catch ex As Exception
  ' Here I want to close the login window by using cnOdbc.Close() or        

    cnOdbc.Dispose()?
  ' Or if the timeout occurs, the window would be closed automatically?
End Try

I'm using VS 2005, I haven't found anything that would say the
ConnectionTimeout property is not supported.
Thank you!

Author
6 Dec 2006 9:10 PM
Eve
I got a suggestion from another forum to open a connection on a separate
thread and kill the thread if it reaches the timeout. It worked.

Show quote
"Eve" wrote:

> If the user name or password is invalid as I'm attempting to make a
> connection, I get the login window. The problem with that is when my
> application runs as a service, the user can't really enter that information,
> so I just want to set up a timeout and when the error gets generated, I want
> to close the login window. Here's my code, but the timeout never occurs, what
> am I doing wrong?
>
> Try
>   Dim cnOdbc As OdbcConnection
>   cnOdbc = New OdbcConnection(strConnectionString)
>   cnOdbc.ConnectionTimeout = 600
>   cnOdbc.Open()
> Catch ex As Exception
>   ' Here I want to close the login window by using cnOdbc.Close() or        
>   
>     cnOdbc.Dispose()?
>   ' Or if the timeout occurs, the window would be closed automatically?
> End Try
>
> I'm using VS 2005, I haven't found anything that would say the
> ConnectionTimeout property is not supported.
> Thank you!
>

AddThis Social Bookmark Button