问题
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:
回答1:
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)
来源:https://stackoverflow.com/questions/12804636/cannot-create-active-x-object