Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

VBscript SQL query hangs script

Avatar of neoptoent
neoptoentFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2005VB ScriptMicrosoft SQL Server 2008SQL
62 Comments1 Solution2053 ViewsLast Modified:

I have a vbscript that querys a SQL database and put the records in to a text file. (CSV)
the issue I am having is if there are too many records to pull the script just never end and hogs 50% of the cpu

I tried to put in a an commandtimeout thinking it would cause the timeout and end the script, but it did nothing

IF there are not that many records to query, it works fine.. it just happens when there are thousands of records

I need a way to have the script stop so that it doesnt continue to hold the processor

The arrlist has my sql query in it
Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionTimeout = 15
objConn.CommandTimeout = 10
Set objRS = CreateObject("ADODB.Recordset")
objConn.Open StrConnectString
set objRS = objConn.Execute (arrlist)
intCount = 0
Do While Not objRS.EOF
  nRow = nRow + 1
  For i = 0 to objRS.Fields.Count - 1 
    stat1 = stat1 & objRS.Fields(i) & "," 
  stat1 = stat1 & vbcrlf

Do While Not objRS.EOF
  nRowC = nRowC + 1
  if nRowC = nRow then
  End If
set objRS = Nothing
set objConn = Nothing

data.WriteLine stat1
if LastEvent <> "" then
  Set f2 = fso.OpenTextFile(c:\test.log",2 , True)
  write.writeLine LastEvent
end if
Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionTimeout = 5
objConn.CommandTimeout = 5
Set objRS = CreateObject("ADODB.Recordset")
Set objTextFile = objFSO.OpenTextFile(c:\test1.log", 1)
Do Until objTextFile.AtEndOfStream
  strread = strread & objTextFile.ReadLine & vbTab
Avatar of aikimark
aikimarkFlag of United States of America imageGet vaccinated; Social distance; Wear a mask
This problem has been solved!
Unlock 1 Answer and 62 Comments.
See Answers