Jump to content
Sign in to follow this  
Ace08

Timeout expired on large queries SQL

Recommended Posts

Ace08

Hi there i have this piece of code that works fine for small queries however i'm getting timeout expired on complex queries.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=server;DATABASE=db;UID=User;PWD=Password2;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open("select count(*) from table",$conn)
$Inc = $rs.Fields(0).value
$rs.close
$rs.Open("select lname, fname, mname, school, address1, address2, city, state from table",$conn)
Do
If $rs.EOF() Then ExitLoop
$cont = $cont & Chr(34) & $rs.Fields(0).value & Chr(34) & "," & Chr(34) & $rs.Fields(1).value & Chr(34) & "," & Chr(34) & $rs.Fields(2).value & Chr(34) & "," & Chr(34) & $rs.Fields(3).value & Chr(34) & "," & Chr(34) & $rs.Fields(4).value & Chr(34) & "," & Chr(34) & $rs.Fields(5).value & Chr(34) & "," & Chr(34) & $rs.Fields(6).value & Chr(34) & "," & Chr(34) & $rs.Fields(7).value & Chr(34) & @CRLF
$rs.MoveNext()
Until $rs.EOF()
$rs.close
MsgBox(0,"debug",$cont)
Func MyErrFunc()
Local $HexNumber
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"COM Test","We intercepted a COM Error !"     & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "       & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "       & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile     & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
  Exit
Endfunc

I've tried doing someting like

$DSN = "DRIVER={SQL Server};SERVER=server;DATABASE=db;UID=User;PWD=Password2;Connection Timeout=0;"

Sorry for posting twice have accidently clicked post and stop ie tought it was'nt posted yet :graduated:

Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites
LarryDalooza

There should be a property you can set on the "connection object" to affect the timeout value. I have used it in a past life.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites
Xenobiologist

Have a look here

http://www.w3schools.com/ado/ado_ref_connection.asp

CommandTimeout


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×