Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to comp.databases.ms-sqlserver,microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Timeout Expired

Hi,

I'm connecting to a SQL server (7.0) from Excel and VBA.

I've checked the VBA and don't think I've got this wrong but I keep
getting a Timeout Expired error message. Is there a setting in SQL
that I am not aware of that I need to set? Could it be the connection
string I use?


The connection string is

Sub SQLConnection()

Dim strConnection As String
Dim Catalogue As String

Dim sSQL As String
Set SQLConn = New ADODB.Connection ' Connection Object

strConnection = "Provider='SQLOLEDB';Data Source='TEST\TEST';Initial
Catalog=composites;User ID=sa;pwd=mypassword"


SQLConn.ConnectionString = strConnection
SQLConn.ConnectionTimeout = 0 ' wait indefinately?
SQLConn.Open


End Sub


The point at which I get the time out is when I run a large update
query

SQLConn.Execute CreateSQL(i + 1)

CreateSQL is a function that updates a table with a million or so
records and about 30 inner joins (takes approx 40 seconds to execute
through Query Analyser).


Any Help much appreciated!

ct

  #2   Report Post  
Posted to comp.databases.ms-sqlserver,microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Timeout Expired

If you set your connection timeout to zero, I don't think that means to
wait indefinitely. Plus, that just sets how long to wait before you
make a connection to your database. What you want to set is the
CommandTimeout. The default wait is 30 seconds if you don't set it.
The CommandTimeout will say how long to wait for your update to
complete.

HTH,
Jennifer

  #3   Report Post  
Posted to comp.databases.ms-sqlserver,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Timeout Expired

I believe you want to set the connection CommandTimeout property to zero.
That specifies the max time a query can run when you invoke the connection
Execute method.

Separately, it's a bad practice to use 'sa' for routine application access.
Use a minimally privileged account.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"cheesey_toastie" wrote in message
oups.com...
Hi,

I'm connecting to a SQL server (7.0) from Excel and VBA.

I've checked the VBA and don't think I've got this wrong but I keep
getting a Timeout Expired error message. Is there a setting in SQL
that I am not aware of that I need to set? Could it be the connection
string I use?


The connection string is

Sub SQLConnection()

Dim strConnection As String
Dim Catalogue As String

Dim sSQL As String
Set SQLConn = New ADODB.Connection ' Connection Object

strConnection = "Provider='SQLOLEDB';Data Source='TEST\TEST';Initial
Catalog=composites;User ID=sa;pwd=mypassword"


SQLConn.ConnectionString = strConnection
SQLConn.ConnectionTimeout = 0 ' wait indefinately?
SQLConn.Open


End Sub


The point at which I get the time out is when I run a large update
query

SQLConn.Execute CreateSQL(i + 1)

CreateSQL is a function that updates a table with a million or so
records and about 30 inner joins (takes approx 40 seconds to execute
through Query Analyser).


Any Help much appreciated!

ct



  #4   Report Post  
Posted to comp.databases.ms-sqlserver,microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Timeout Expired

Wonderful.


I stared at that for ages.... !!

Many thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find expired dates =IF((E11-TODAY()<0), "EXPIRED", "OK") Jo Excel Worksheet Functions 1 June 5th 07 12:42 AM
TImeIn-TimeOut-TimeIn-TimeOut-HoursWorked ChefBoiRD Excel Worksheet Functions 3 September 20th 05 10:01 AM
Timeout tcbootneck Excel Programming 1 July 15th 05 11:48 AM
Connection with SQL Server generate "Timeout expired" joaovtt[_3_] Excel Programming 7 June 25th 05 11:53 AM
COM server timeout Erich Neuwirth Excel Programming 0 July 6th 04 09:40 AM


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"