Hi,
We have a COM object that has loaded data from SQL Server 2000 to an XML file to use in our web application.
However we are migrating to 2005 using the same COM object but are having problems; namely with the connection string (db,user,password and server details replaced):
-<add name="BulkLoadConnectionString" connectionString="Provider=SQLOLEDB;Server=<ServerIP>;Initial Catalog=<db>;User ID=<user>;Password=<passwd>/>
I read that SQLOLEDB won't work with 2005 and I need to use SQL's native client. So, now it looks like this:
<add name="BulkLoadConnectionString" connectionString="Provider=SQLNCLI;Server=<server IP>;Initial Catalog=<db>;User ID=<user>;Password=<passwd>" />
When our COM is run our log file reveals:
System.Runtime.InteropServices.COMException (0x80040154): Invalid connection string.
at SQLXMLBULKLOADLib.SQLXMLBulkLoadClass.ISQLXMLBulkLoad_Execute(String bstrSchemaFile, Object vDataFile)
at <our WebService>.ExecuteBulkLoad(String xsdFile, String xmlFile)
The code snippet that fails is the bulkLoad.ConnectionString assignment:
publicvoid ExecuteBulkLoad(string xsdFile, string xmlFile)
{
ISQLXMLBulkLoad bulkLoad = new SQLXMLBULKLOADLib.SQLXMLBulkLoadClass ();SQLXMLBULKLOADLib.
bulkLoad.KeepIdentity =
false;bulkLoad.ForceTableLock =
true;try
{
bulkLoad.ConnectionString = _bulkLoadConnectionString;
bulkLoad.Execute(xsdFile, xmlFile);
}
catch (Exception ex){
log.Error(ex.Message, ex);
}
}
Please take a leap of faith and assume the connection string does exist! I can vouch that this is the case.
I've tried adding the STAThread attribute as was suggested on another MSDN thread and SQL's native client as already mentioned.
That's about as much info as I have. Can anyone help?
Paul