Jump to content

Timeout expired on large queries SQL


Ace08
 Share

Recommended Posts

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;"

with no luck even tried doing

$conn.ConnectionTimeout = 0

with same results

Work smarter not harder.My First Posted Script: DataBase

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...