2012-01-09 2 views
2

우리가 가지고있는 오래된 레거시 vbscript 코드에는 일종의 오류가 필요합니다. 전에 vbscript를 사용 해 본 적이 없기 때문에 저는 완전히 손해를보고 있습니다. 내가이 줄을 확신vbscript에서 오류 처리?

set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.4.0") 
objBL.ConnectionString = "connectionstring" 
objBL.KeepIdentity = false 
objBL.ErrorLogFile = "E:\code\Acquity\WebOrderImport\logs\error.log" 

Set fso = CreateObject("Scripting.FileSystemObject") 
Set parentfolder = fso.GetFolder("E:\textdata\Acquity\AcquityWebOrders") 
Set logfile = fso.OpenTextFile("E:\code\Acquity\WebOrderImport\logs\import.log",8) 
count = 0 
    For each folder in parentfolder.subfolders 
     logfile.writeline count & " files" 
     logfile.writeline "Processing " & folder.name & " ***********************************" & now() 
     count = 1 
     For Each file in folder.files 
      If left(file.name,6) = "Order_" then 
       If left(file.name,13) = previous then 
        logfile.writeline "!!!!! SKIPPING file " & file.name & "!!!!! DUPED ORDER ID" 
       Else 
        logfile.writeline "reading " & file.name   
        objBL.Execute "E:\code\Acquity\WebOrderImport\acq_WebOrder_import.xsd", file.path     
        count=count+1 
       End If 
      previous = left(file.name,13) 
      End If 
     Next 
    Next  

set objBL=Nothing 
logfile.writeline "Done!" 
Set logfile = nothing 
Set parentfolder = nothing 
set fso = nothing 

: 여기에 코드입니다

bjBL.Execute "E:\code\Acquity\WebOrderImport\acq_WebOrder_import.xsd", file.path 

예외를 던지는 유지하고, 나는 그것이 오류를 칠 때 실행하는 것이 아니라 정지 유지하기 위해 코드가 필요합니다. 어떻게해야합니까?

답변

5

, 오류를 무시를 일으킬 수있는 부분 전에 On Error Resume Next를 추가 할 수 있습니다. "다음 재개"효과를 사용하지 않으려면 On Error Goto 0을 사용하십시오.

+0

VBScript의 오류 트래핑에 대한 자세한 내용은 ASP Free에서 기사를 읽으십시오. http://www.aspfree.com/c/a/Windows-Scripting/Error-Trapping-and-Capturing-ThirdParty-Output-in-WSH/ – Nilpo

3

코드를 계속 실행하려면 (매우) 더러운 방법으로 파일의 맨 위에 On Error Resume Next을 추가하면 오류가 발생하면 실행이 행복하게 수행됩니다.

2

이 기술로 약간 연습했지만 AFAIK vbscript는 런타임 예외 (On Error Resume Next)를 처리하는 유일한 방법이 있습니다.

당신은이 기사를 읽을 수 있습니다 : MSDN article하고 더 도움이 날 about handling and notifying.