dbTalk Databases Forums  

Skip invalid XML files while XMLBulkLoading Multiple Files so that the DTS doesn't stop at the error?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Skip invalid XML files while XMLBulkLoading Multiple Files so that the DTS doesn't stop at the error? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Grant
 
Posts: n/a

Default Skip invalid XML files while XMLBulkLoading Multiple Files so that the DTS doesn't stop at the error? - 03-11-2005 , 03:32 AM






Hi to everybody!

I'm doing a XML Bulk Load of multiple XML files and given that there
are a lot of them, it must fully be automatic. However some of these
files have not been validated and contain errors that stop executing
the DTS. As a result, I must extract the problematic XML files and
restart the process which means human intervention.

Does anybody know a way to make the ActiveX DTS continue Bulk Loading
the rest of XML files when an error is found? Can it be done at the
VBS level? (I've also posted my VBS script).

Any help will be wellcomed.

Function Main()

Dim objSQLXMLBulkLoad
Set objSQLXMLBulkLoad =
CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad.3.0")
objSQLXMLBulkLoad.ConnectionString = _
"PROVIDER=SQLOLEDB.1;SERVER=.;UID=sa;PWD=;DATABASE =FinalMultiple;"
objSQLXMLBulkLoad.SchemaGen = true
objSQLXMLBulkLoad.SGDropTables = false
objSQLXMLBulkLoad.CheckConstraints = True
objSQLXMLBulkLoad.SGUseID=True
objSQLXMLBulkLoad.KeepIdentity = False

Dim sFolder
sFolder="C:\Multiple\"

Dim fso, f, f1, fc, s

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sFolder)
Set fc = f.Files
For Each f1 in fc

objSQLXMLBulkLoad.ErrorLogFile = "C:\Error.log"
objSQLXMLBulkLoad.Execute "C:\Modified_data\file.xsd", sFolder &
f1.name

Next

Set objSQLXMLBulkLoad = Nothing

Main = DTSTaskExecResult_Success
End Function


Greetings,
David Grant

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Skip invalid XML files while XMLBulkLoading Multiple Files so that the DTS doesn't stop at the error? - 03-11-2005 , 09:24 AM






Error handling in VBS is a bits pants, but you could do something like this-

For Each f1 in fc


objSQLXMLBulkLoad.ErrorLogFile = "C:\Error.log"
On Error Resume Next ' Supress errors
objSQLXMLBulkLoad.Execute "C:\Modified_data\file.xsd", sFolder &
f1.name
If Err.Number <> 0 Then ' check if we had an error
' Do something as this file failed
End If
On Error GoTo 0 ' turn normal error failures back on

Next

"David Grant" <icebold54 (AT) hotmail (DOT) com> wrote

Quote:
Hi to everybody!

I'm doing a XML Bulk Load of multiple XML files and given that there
are a lot of them, it must fully be automatic. However some of these
files have not been validated and contain errors that stop executing
the DTS. As a result, I must extract the problematic XML files and
restart the process which means human intervention.

Does anybody know a way to make the ActiveX DTS continue Bulk Loading
the rest of XML files when an error is found? Can it be done at the
VBS level? (I've also posted my VBS script).

Any help will be wellcomed.

Function Main()

Dim objSQLXMLBulkLoad
Set objSQLXMLBulkLoad =
CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad.3.0")
objSQLXMLBulkLoad.ConnectionString = _
"PROVIDER=SQLOLEDB.1;SERVER=.;UID=sa;PWD=;DATABASE =FinalMultiple;"
objSQLXMLBulkLoad.SchemaGen = true
objSQLXMLBulkLoad.SGDropTables = false
objSQLXMLBulkLoad.CheckConstraints = True
objSQLXMLBulkLoad.SGUseID=True
objSQLXMLBulkLoad.KeepIdentity = False

Dim sFolder
sFolder="C:\Multiple\"

Dim fso, f, f1, fc, s

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sFolder)
Set fc = f.Files
For Each f1 in fc

objSQLXMLBulkLoad.ErrorLogFile = "C:\Error.log"
objSQLXMLBulkLoad.Execute "C:\Modified_data\file.xsd", sFolder &
f1.name

Next

Set objSQLXMLBulkLoad = Nothing

Main = DTSTaskExecResult_Success
End Function


Greetings,
David Grant



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.