0

I'm running into an error and I cannot figure out what's wrong with the code. It happens when I try to create an object (objbl = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.4.0")).

Am I missing anything?

Try
            objbl = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.4.0") // error happens on this line.
            objbl.ConnectionString = ReadVariables("ConnectionString")

            Console.WriteLine(objbl.connectionstring.ToString)

            objbl.ErrorLogFile = workingdirectory & "\error.log"
            objbl.TempFilePath = workingdirectory & "" 'workingdirectory
            objbl.CheckConstraints = True
            objbl.KeepIdentity = False
            objbl.Transaction = True

            'objbl()

        Catch ex As System.Exception
            Console.WriteLine("Error initializing SQL Bulk load object." & Chr(13) & Chr(10) & ex.ToString)
            WritetxtToLog("Error initializing SQL Bulk load object." & Chr(13) & Chr(10) & ex.ToString, 1)
            Exit Sub
        End Try

Here's exception error:

System.Exception was caught Message="Cannot create ActiveX component." Source="Microsoft.VisualBasic" StackTrace: at Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String ServerName) at XMLshredapp.XMLShredApp.InitBulkLoad() in C:\ShredApp\XMLshredapp\XMLShredApp.vb:line 460 InnerException:

JJ.
  • 9,580
  • 37
  • 116
  • 189

1 Answers1

0

Those errors "ActiveX can not create object" generally mean that the ProgID you supplied to CreateObject is unknown.

In other words, you get this error if the ProgID (SQLXMLBulkLoad.SQLXMLBulkload.4.0) was mistyped or belongs to a DLL that is not registered in the registry.

Can you search the registry on the machine where you are running this application and see if the SQLXMLBulkLoad exists in the registry? if it does not, you need to find that DLL and register it (with regsvr32)

Jason
  • 1,385
  • 9
  • 11
  • how do I check the registry for this? – JJ. Oct 09 '12 at 19:07
  • Open up the program regedit, Ctrl-F, and search for SQLXMLBulkLoad. If it doesn't find anything, then it isn't registered. If you find nothing, then you need to get the DLL containing the definition of SqlXmlBulkLoad and register it. – Jason Oct 09 '12 at 19:26
  • Found it. its there. now what? its called "SQLXMLBulkLoad Class" – JJ. Oct 09 '12 at 19:34
  • My assumption was that the file would not be there. Since it is, I am out of my element and would only be guessing at a solution. Sometimes, in 64-bit systems, I have had success registering a DLL with %SystemRoot%\SysWow64\regsvr32 even if it is present in the registry already, but you would need to find where the DLL is located and I am not entirely sure why that works when it does. – Jason Oct 09 '12 at 19:39
  • Jason, %SystemRoot%\SysWow64\regsvr32 and then what? what file am I putting after regsvr32? – JJ. Oct 09 '12 at 20:57
  • I'm not sure. According to Microsoft, you shoudln't be needing to tweak the registry at all, so that might be the wrong approach. Could you verify that you have installed Microsoft SqlXML 4.0 SP1 from Microsoft: http://www.microsoft.com/en-us/download/details.aspx?id=3522 Scroll down to the 'Microsoft SqlXML 4.0 SP1' Perhaps the version you have is an older version. You can also try modifying your CreateObject statement to just say CreateObject("SQLXMLBulkLoad.SQLXMLBulkload") for the version-independent object. Maybe that helps. – Jason Oct 09 '12 at 21:17