0

We have a VBScript that downloads chunks of data from an SAP Business Object database into so-called slices, which are basically .csv files. The script worked perfectly so far, I haven't really had to look into it at all. But the failure now is this:

Error popup

The script file section this error refers to is the dbConn.Execute(strSQL) line in the below code (5th from below). What I tried so far, was to add these commands but they don't seem to solve anything:

'dbConn.ConnectionTimeout = 100
'dbConn.CommandTimeout = 100

The script itself (not all of it, I'm not sure the rest is needed):

Sub subRunFilesInFolder(strFolder)
  Dim FSO, objFolder, objFiles
  Dim i, intTS, intTS_file_start, ts, tsKillBefore, TS_file_start, strModelName
  Dim dbConn, RST, RST2, strSQL
  Dim strVBSmodel
  Dim blRunIt

  'INIs
  strModelName = "bo_vbs_runner_1.5 "
  strConn = "DRIVER={SQL Server};SERVER=EUBASEURCIREP01;UID=ser_login;PWD=ser_login;DATABASE=ser"
  strComputer = FunstrComputerName
  strBORunner = "\\Eubaseurcirep01\reporting\DEVELOPMENT\BO\Automation\Models\BO_auto_run.xlsb"

  'Sets
  Set dbConn = CreateObject("ADODB.Connection")
  Set RST = CreateObject("ADODB.RecordSet")
  Set RST2 = CreateObject("ADODB.RecordSet")
  Set WshShell = WScript.CreateObject("WScript.Shell")
  Set FSO = Wscript.CreateObject("Scripting.FileSystemObject")
  Set objFolder = FSO.GetFolder(strFolder)
  Set objFiles = objFolder.Files
  Set appExcel = CreateObject("Excel.Application")

  'dbConn.ConnectionTimeout = 100
  'dbConn.CommandTimeout = 100

  strVBSmodel = strModelName & strComputer & " " & FunstrUserName & " " &  funCurrProcessId & " " & FunGetProcessIDCurrentOfExcel(strComputer)
  appExcel.Application.Visible = False
  appExcel.Displayalerts = False
  Set objBORunner = appExcel.Workbooks.Open(strBORunner)

  dbConn.Open strConn
  ts = FunGetServerNow(dbConn,RST)
  tsKillBefore = DateAdd("N", -15, ts)
  intTS = funTimeStampToInteger(FunGetServerNow(dbConn, RST))

  'Get ReportDate
  strSQL = "SELECT yyyymmdd FROM map.reportdate WHERE dtAct=cast(GETDATE() as DATE);"
  RST.Open strSQL, dbConn
  If RST.EOF Then
    strReportDate="99991231"
  Else
    strReportDate=RST.fields(0).value
  End If
  RST.close


  'Kill stucked excel and vbs processes
  strSQL = "SELECT distinct * FROM [ser].[bo].[_log] WHERE [proc]='BO VBS' AND result_text='started' AND end_timestamp<" & funTimeStampToInteger(tsKillBefore) & _
      " AND lower(model) like '% " & LCase(strComputer) & " %';"
  RST.Open strSQL,dbConn
  If RST.EOF Then 'Nothing to kill
  Else
    Do While Not RST.EOF
      strOldVBS = split(RST.fields("model"), " ")(3)
      strOldExcel = split(RST.fields("model"), " ")(4)
      Call SubKillProcessIDOnstrComputer(strComputer, strOldVBS)
      Call SubKillProcessIDOnstrComputer(strComputer, strOldExcel)

      strSQL = "UPDATE [ser].[bo].[_log] SET result_text='stopped', end_timestamp='" & funTimeStampToInteger(FunGetServerNow(dbConn,RST2)) & "' " & _
          "WHERE [proc]='BO VBS' AND result_text='started' AND model='" & RST.fields("model").value & "' AND parameters='" & _
          RST.fields("parameters").value & "';"
      dbConn.Execute(strSQL)
      RST.MoveNext
    Loop
  End If
  RST.close
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • Does it help to set the timeout to `0`? According to the doc the command should then run "as long as it needs": `If you set the property to zero, ADO will wait indefinitely until the execution is complete.` - https://msdn.microsoft.com/en-us/library/ms678265%28v=vs.85%29.aspx – erg Dec 30 '15 at 09:58
  • Well this sounds good - but I'm afraid something gets stuck, because since I set the timeouts to 0 th error didn't emerge but nothing else has happened either. Script has been running for half an hour now - first slices should have arrived in a few minutes. – user2870283 Dec 30 '15 at 10:52
  • Yes, sounds like the query is blocked in sql server itself. I would try to analyze on the server-side whats causing the blocking, using the tools from sql server - I dont know how to do that, but this here seems like a start: http://stackoverflow.com/questions/941763/list-the-queries-running-on-sql-server Also I would try to identify if anything has changed on the server-side, etc. Good luck and happy new year ! PS: And of course try the obvious things like rebooting / restarting sql server.. – erg Dec 31 '15 at 11:21
  • wheew... i don't have access to this server so this will be tough... thanks for the ideas anyway :) – user2870283 Jan 04 '16 at 08:55

1 Answers1

0

To Decode 0x8004nnnn Errors

HResults with facility code 4 means the HResult contains OLE errors (0x0 = to 0x1ff) while the rest of the range (0x200 onwards) is component = specific errors so 20e from one component will have a different meaning = to 20e from another component.

You are lucky as your component is telling you it's OLDB with it's error - TIMEOUT