473,508 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Server Connection Timeout

Hi,

I have an application that uses ADO & VBA to connect to SQL Server 2000
periodically like this:

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionTimeout = 1
conn.ConnectionString =
"Provider=SQLOLEDB;Server=MyServer;Database=MyData base;UID=MyUserID;PWD=MyPa
ssword"
conn.Open

When the server is unavailable, the Open waits 60 seconds before timing out.
During this time, the application is locked up because the VBA is not
reentrant. Doesn't the ConnectionTimeout property determined the connection
timeout? Where is the seconds coming from?

Please advise,
Tony Perovic
Compumation, Inc.
Jul 20 '05 #1
3 26075
"tperovic" <to*********@yahoo.com> wrote in message news:<Nr*****************@newsread3.news.atl.earth link.net>...
Hi,

I have an application that uses ADO & VBA to connect to SQL Server 2000
periodically like this:

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionTimeout = 1
conn.ConnectionString =
"Provider=SQLOLEDB;Server=MyServer;Database=MyData base;UID=MyUserID;PWD=MyPa
ssword"
conn.Open

When the server is unavailable, the Open waits 60 seconds before timing out.
During this time, the application is locked up because the VBA is not
reentrant. Doesn't the ConnectionTimeout property determined the connection
timeout? Where is the seconds coming from?

Please advise,
Tony Perovic
Compumation, Inc.

Hi Tony
As per my knowledge about ConnectionTimeOut, if u set it to zero
then the connection attempt waits indefinitely. Does this rule also
employ to lower values of TimeOut is a question which i am not sure
about.

With Regards
Debashish
Jul 20 '05 #2
I've tried values of 1,5,10 and 15 and the result is always the same - it
takes sixty seconds to timeout.

"debashish" <de****************@rediffmail.com> wrote in message
news:bb**************************@posting.google.c om...
"tperovic" <to*********@yahoo.com> wrote in message

news:<Nr*****************@newsread3.news.atl.earth link.net>...
Hi,

I have an application that uses ADO & VBA to connect to SQL Server 2000
periodically like this:

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionTimeout = 1
conn.ConnectionString =
"Provider=SQLOLEDB;Server=MyServer;Database=MyData base;UID=MyUserID;PWD=MyPa ssword"
conn.Open

When the server is unavailable, the Open waits 60 seconds before timing out. During this time, the application is locked up because the VBA is not
reentrant. Doesn't the ConnectionTimeout property determined the connection timeout? Where is the seconds coming from?

Please advise,
Tony Perovic
Compumation, Inc.

Hi Tony
As per my knowledge about ConnectionTimeOut, if u set it to zero
then the connection attempt waits indefinitely. Does this rule also
employ to lower values of TimeOut is a question which i am not sure
about.

With Regards
Debashish

Jul 20 '05 #3
Hello Tony
From what i know, this is a problem when you connect to oracle
since the MS Oracle ODBC driver and MS OLE DB Provider for Oracle dont
support setting ConnectionTimeout.
This occurs due to a limitation in the Oracle Call Interface(OCI)
and applies to Oracle ODBC driver as well as the Oracle OLEDB
provider. This happens as a result of design specifications.
If one still wants to check the connection status(for Oracle or SQL
server), the following code may work:
You must use the option - adAsyncConnect to open the connection.

'*********************Module declarations*******************

Private Declare Function GetTickCount Lib "Kernel32" () As Long

Public sub ConnectToDatabase()
Dim lngStartTime as Long
Dim conn As New ADODB.Connection
Set conn = New ADODB.Connection
conn.ConnectionTimeout = 10
conn.ConnectionString =
"Provider=SQLOLEDB;Server=MyServer;Database=MyData base;UID=MyUserID;PWD=MyPa
ssword", adAsyncConnect
conn.Open
lngStartTime = GetTickCount()

Do While ((GetTickCount() - lngStartTime) < conn.ConnectionTimeOut
* 1000)
And (Not conn.State = adStateOpen)
Loop

If Not conn.State = adStateOpen Then
If conn.State = adStateConnecting Then
conn.Cancel
End If
Else
MsgBox "Connection Successfull!"
conn.close
End If

End Sub

'*****Module ends*****

Hope this works for SQL server also! Do let me know if this works.

With Regards
Debashish
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3912
by: Dicky Cheng | last post by:
Hi, I am using .net remoting technology. I set up a .net remoting client and server in IIS. When the client calls the server, the server will run a long duration method (30-60seconds). I have a...
3
13957
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection...
2
1519
by: Bernie Yaeger | last post by:
I'm getting the following error - not always, only randomly - when I run a certain routine (the routine is a simple executenonquery and it appears to complete despite the message) against sql...
8
5756
by: BBC1009 | last post by:
I have an application connected to an overseas sql-server using port 1433. But recently it always timeout the connection. Any solution to avoid this??? I am using the VB.net Windowed Form with...
4
13156
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying...
14
6995
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
25
14464
by: _DD | last post by:
I'd like to include a 'Test Connection' button in an app, for testing validity of a SQL connection string. I'd prefer to keep the timeout low. What is the conventional way of doing this?
2
5079
by: RyoSaeba | last post by:
Hello, I have a problem with the session state set to Sql Server (AspNet 1.1, Windows Server 2003 on an Application Center cluster, Sql Server 2000 on another server). Sometimes, when many user...
2
9789
by: JoeSep | last post by:
Hi! Is it correct/safe to define a connection pool in the string "sqlConnectionString" of the "sessionState" section of Web.config? - The application is developed using AspNet 1.1 in a Windows...
3
3083
by: =?Utf-8?B?QXho?= | last post by:
Is there a limitation on the number of (sequential) opened connection for SQL Server User Instances? The following method will run to about the 240th iteration then will receive a timeout...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.