Home > Archive > MS SQL XML > October 2005 > SQL Xml Bulk Load thread won't start









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL Xml Bulk Load thread won't start
Doug Kent

2005-10-27, 9:26 am

Hi,

I am using a STA thread to run a SQLXMLBulkLoad3 COM object.

On a couple of machines the thread runs fine. On another machine the thread
won't start, and no exceptions are thrown.

This code is running in a web service implemented using C#, ASP.NET 1.1, IIS
5.1, Windows 2000 Server.

Any suggestions appreciated! Here is some code. The method
xmlLoader.Load() is never invoked.

To start the thread:

XmlBulkLoader xmlLoader = new XmlBulkLoader();
ThreadStart workThreadDelegate = new ThreadStart(xmlLoade
r.Load);
Thread workThread = new Thread(workThreadDel
egate);
workThread.ApartmentState = ApartmentState.STA;
workThread.Name = "XMLBulkLoader";
workThread.Start();
workThread.Join();

The code that is not running when it should (xmlLoader.Load):

public class XmlBulkLoader
{
public void Load()
{
ADODB.Stream xmlDataStream = null;
try
{
xmlDataStream = new ADODB.StreamClass();
xmlDataStream.Open(System.Type.Missing,
ADODB.ConnectModeEnum.adModeUnknown,
ADODB. StreamOpenOptionsEnu
m. adOpenStreamUnspecif
ied,
null, null);
xmlDataStream.WriteText(_xmlData, ADODB.StreamWriteEnum.adWriteChar);
xmlDataStream.Position = 0;
SQLXMLBulkLoad3 objBL = new SQLXMLBulkLoad3();
objBL. ConnectionString=_db
Connection;
objBL.ErrorLogFile = Path. Combine(_logFilePath
, "sqlbulkloaderror.log");
objBL.CheckConstraints = true;
objBL.Transaction = true;
objBL.XMLFragment = false;
objBL.SchemaGen = false;
objBL.KeepIdentity = false;
objBL.KeepNulls= false;
objBL.IgnoreDuplicateKeys = false;
objBL.ForceTableLock = false;
objBL.SGDropTables = false;
objBL. Execute(_schemaFile,
xmlDataStream);
}
catch(Exception ex)
{
exception = ex;
}
finally
{
if (xmlDataStream != null)
{
xmlDataStream.Close();
}
}
}
}



Doug Kent

2005-10-27, 9:26 am

What bugs me is that ASP.NET is behaving as though the thread were running,
when in fact its not.

After calling Start() the thread state is 'Unstarted'.

-d


"Doug Kent" <dkent@_n_o_s_p_a_m.austin.rr.com> wrote in message
news:6u94f.37898$Q53.4109@tornado.texas.rr.com...
> Hi,
>
> I am using a STA thread to run a SQLXMLBulkLoad3 COM object.
>
> On a couple of machines the thread runs fine. On another machine the
> thread
> won't start, and no exceptions are thrown.
>
> This code is running in a web service implemented using C#, ASP.NET 1.1,
> IIS
> 5.1, Windows 2000 Server.
>
> Any suggestions appreciated! Here is some code. The method
> xmlLoader.Load() is never invoked.
>
> To start the thread:
>
> XmlBulkLoader xmlLoader = new XmlBulkLoader();
> ThreadStart workThreadDelegate = new ThreadStart(xmlLoade
r.Load);
> Thread workThread = new Thread(workThreadDel
egate);
> workThread.ApartmentState = ApartmentState.STA;
> workThread.Name = "XMLBulkLoader";
> workThread.Start();
> workThread.Join();
>
> The code that is not running when it should (xmlLoader.Load):
>
> public class XmlBulkLoader
> {
> public void Load()
> {
> ADODB.Stream xmlDataStream = null;
> try
> {
> xmlDataStream = new ADODB.StreamClass();
> xmlDataStream.Open(System.Type.Missing,
> ADODB.ConnectModeEnum.adModeUnknown,
>
> ADODB. StreamOpenOptionsEnu
m. adOpenStreamUnspecif
ied,
> null, null);
> xmlDataStream.WriteText(_xmlData, ADODB.StreamWriteEnum.adWriteChar);
> xmlDataStream.Position = 0;
> SQLXMLBulkLoad3 objBL = new SQLXMLBulkLoad3();
> objBL. ConnectionString=_db
Connection;
> objBL.ErrorLogFile = Path. Combine(_logFilePath
,
> "sqlbulkloaderror.log");
> objBL.CheckConstraints = true;
> objBL.Transaction = true;
> objBL.XMLFragment = false;
> objBL.SchemaGen = false;
> objBL.KeepIdentity = false;
> objBL.KeepNulls= false;
> objBL.IgnoreDuplicateKeys = false;
> objBL.ForceTableLock = false;
> objBL.SGDropTables = false;
> objBL. Execute(_schemaFile,
xmlDataStream);
> }
> catch(Exception ex)
> {
> exception = ex;
> }
> finally
> {
> if (xmlDataStream != null)
> {
> xmlDataStream.Close();
> }
> }
> }
> }
>
>
>



Doug Kent

2005-10-27, 9:26 am

OK, this has nothing to do with SQL Bulk Load or COM or STA threads.
Removing all meaningful code and the thread *still* won't start. Just a
plain old thread.



Doug Kent

2005-10-27, 9:26 am

Turns out a referenced dll was not present. Unfortunate that the thread
gave no clue.


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com