473,835 Members | 1,829 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.Connectio n
Set conn = New ADODB.Connectio n
conn.Connection Timeout = 1
conn.Connection String =
"Provider=SQLOL EDB;Server=MySe rver;Database=M yDatabase;UID=M yUserID;PWD=MyP a
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 ConnectionTimeo ut property determined the connection
timeout? Where is the seconds coming from?

Please advise,
Tony Perovic
Compumation, Inc.
Jul 20 '05 #1
3 26093
"tperovic" <to*********@ya hoo.com> wrote in message news:<Nr******* **********@news read3.news.atl. earthlink.net>. ..
Hi,

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

Dim conn As ADODB.Connectio n
Set conn = New ADODB.Connectio n
conn.Connection Timeout = 1
conn.Connection String =
"Provider=SQLOL EDB;Server=MySe rver;Database=M yDatabase;UID=M yUserID;PWD=MyP a
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 ConnectionTimeo ut property determined the connection
timeout? Where is the seconds coming from?

Please advise,
Tony Perovic
Compumation, Inc.

Hi Tony
As per my knowledge about ConnectionTimeO ut, 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.goo gle.com...
"tperovic" <to*********@ya hoo.com> wrote in message

news:<Nr******* **********@news read3.news.atl. earthlink.net>. ..
Hi,

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

Dim conn As ADODB.Connectio n
Set conn = New ADODB.Connectio n
conn.Connection Timeout = 1
conn.Connection String =
"Provider=SQLOL EDB;Server=MySe rver;Database=M yDatabase;UID=M yUserID;PWD=MyP a 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 ConnectionTimeo ut property determined the connection timeout? Where is the seconds coming from?

Please advise,
Tony Perovic
Compumation, Inc.

Hi Tony
As per my knowledge about ConnectionTimeO ut, 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 ConnectionTimeo ut.
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 ConnectToDataba se()
Dim lngStartTime as Long
Dim conn As New ADODB.Connectio n
Set conn = New ADODB.Connectio n
conn.Connection Timeout = 10
conn.Connection String =
"Provider=SQLOL EDB;Server=MySe rver;Database=M yDatabase;UID=M yUserID;PWD=MyP a
ssword", adAsyncConnect
conn.Open
lngStartTime = GetTickCount()

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

If Not conn.State = adStateOpen Then
If conn.State = adStateConnecti ng 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
3947
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 test on it that if the network broken at the time the client have already send the remoting request and waiting for the server, the client side will wait infinitely by default, even if i already set the executionTimeout to 90seconds in...
3
14002
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 connection = new SqlConnection(ConfigurationSettings.AppSettings)) {
2
1540
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 server 2000: "timout expired. The timeout period elapsed prior to completion of the operation or the server is not responding" Anyone have any idea what causes this and how to avoid it? Thanks for any help.
8
5774
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 .net 2002, SQL-Sever 2000 Enterprise Thanks!
4
13202
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 to login (obviously it's using ASPNETDB.mdf). Any ideas? Server Error in '/' Application. --------------------------------------------------------------------------------
14
7047
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 sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
25
14510
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
5129
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 are using the application, we got this error: "System.Web.HttpException: Unable to connect to SQL Server session database. ---System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the...
2
9816
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 Server 2003. - The AspState DB is defined in a Sql Server 2000 DB on another server. I have added this definition to the Web.config file: <sessionState mode="SQLServer"
3
3113
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 exception (SqlException. "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."). If User Instance=false then the method will execute to completion. Note that connection pooling is off just...
0
9652
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10808
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10520
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10233
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9344
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4433
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 we have to send another system
2
3993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3088
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.