SQLXMLBulkLoad

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #5602

    by pogue1000 at 2013-02-27 07:33:49

    I have a vbscript I have done that works great but I am trying to do everything in Powershell in my scripting lately.
    Set objDL = CreateObject("ADODB.Connection")
    objDL.ConnectionString = "provider=SQLOLEDB.1;data source=Washington;database=SBI;uid=sysadm;pwd=xxxx"
    objDL.Open
    objDL.Execute("delete from wgo_mainframe_parts_test")
    objDL.Close
    Set objBL = Nothing

    Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
    objBL.ConnectionString = "provider=SQLOLEDB.1;data source=Washington;database=SBI;uid=sysadm;pwd=sunny13"
    objBL.ErrorLogFile = "c:\vbscript\error2.log"
    objBL.Execute "c:\vbscript\sunparts_schema.xml", "c:\vbscript\sunnybrook_parts.xml"
    Set objBL = Nothing

    So i was curious how I import the dll for the xmlbulkload.

    I started a script with
    [Reflection.Assembly]::LoadFile('c:\Program Files\Common Files\System\Ole DB\xblkld4.dll')
    However I get the following error when I try to run it. Was curious how i do this in Powershell

    Exception calling "LoadFile" with "1" argument(s): "The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)"
    At C:\Powershell\BulkPartsInsert.ps1:1 char:33
    + [Reflection.Assembly]::LoadFile < <<< ('c:\Program Files\Common Files\System\Ole DB\xblkld4.dll')
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    by DonJ at 2013-02-27 07:43:25

    You can only do that for .NET assemblies, and that one isn't one.


    $bl = New-Object -Com SQLXMLBulkLoad.SQLXMLBulkLoad

    Basically the same as you did in VBScript, just different syntax.

You must be logged in to reply to this topic.