Hi there, hope you can help.
I have a web service to bulk load data from xml to sql server - here's a code snippet:
--------------------------------------------------------------------
System.Threading.Thread.CurrentThread.ApartmentState = System.Threading.ApartmentState.STA;
SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class objXBL = new SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class();
objXBL.ConnectionString = ConfigurationSettings.AppSettings["connString"];
string schemaFile = ConfigurationSettings.AppSettings["schemaFile"];
objXBL.BulkLoad = true;
objXBL.KeepIdentity = false;
objXBL.XMLFragment = true;
objXBL.Transaction = false;
objXBL.Execute(schemaFile, data); //Data is a System.IO.MemoryStream, made of given xml
------------------------------------------------------------
I call this web service from external Windows Application. By saying external I mean separate solution.
Everything works just fine when I add a reference to service's dll and call it like that:
-------------------------------------------------------------
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSubmit_Click(object sender, System.EventArgs e)
{
MyService.Service1 svrDataImport = new MyService.Service1();
svrDataImport.objUserInformation = new MyService.UserInformation();
svrDataImport.objUserInformation.UserName = "login";
svrDataImport.objUserInformation.Password = "pass";
string msg = svrDataImport.LoadDataString(txtData.Text);
txtResult.Text = msg;
}
-------------------------------------------------------
As I said, it works fine like that. But I need to make to work it by adding NOT a reference to dll, but a Web reference. The code I use is a little bit different in this case:
----------------------------------------------------------
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSubmit_Click(object sender, System.EventArgs e)
{
MyAppl.MyService.Service1 svrDataImport = new MyAppl.MyService.Service1(); //MyService is a name of web reference
svrDataImport.UserInformationValue = new MyAppl.MyService.UserInformation();
svrDataImport.UserInformationValue.UserName = "login";
svrDataImport.UserInformationValue.Password = "pass";
string msg = svrDataImport.LoadDataString(txtData.Text);
txtResult.Text = msg;
}
----------------------------------------------------
The error occures on
objXBL.ConnectionString = ConfigurationSettings.AppSettings["connString"];
in web service. Could anyone, please, advice me?
>> Stay informed about: Need help with SQLXMLBulkLoad 3.0 in .NET