473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SQLXMLBULKLOADLib, Threading

Hi All,
I am trying to use SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class to upload
XML Documents to SQL server's Database Table. The moment I made it as
a service I created and started a new Apartment thread to do the
processing.
As the method been called by an event that can fire any moment even
while processing the procedure, it locks the ErrorLogFile associated
with the SQLXMLBulkLoad3Class object. Is there any way than the Event
can wait till the processing of the thread stops and disposes?

I just want to know how to hold the event procedure that calls
function "LoadBulkToSQL"

Thank you in advance
ansu.

Code Sample:

Private Function LoadBulkToSQL(ByVal txtFileName As String, ByVal
txtSchema As String) As Boolean
Dim fCheck As System.IO.File

If fCheck.Exists(txtFileName) = False Or
fCheck.Exists(txtSchema) = False Then
'Some Error Message here
Exit Function
End If

Dim loadThread As New System.Threading.Thread(AddressOf
loadData)
loadThread.ApartmentState = Threading.ApartmentState.STA
'SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class cannot work other than
single threaded environment
_SchemaPath = txtSchema
_XMLFilePath = txtFileName
loadThread.Start()

End Function

'Procedure for a new Thread
Private Sub loadData()
Dim xmlblas As New SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class

xmlblas.BulkLoad = True
xmlblas.ErrorLogFile = GetConfigValue("LOGPATH") 'From
APP.Config file
xmlblas.ConnectionString = "provider=SQLOLEDB.1;Integrated
Security=SSPI;data source=MYDeskServer;initial catalog=TestDB"
xmlblas.ForceTableLock = True
Try
xmlblas.Execute(_SchemaPath.ToString,
_XMLFilePath.ToString)
Catch ex As Exception
xmlblas = Nothing
Dim evt2 As EventLog
evt2.WriteEntry("SampleService", ex.Message & " " &
ex.Source)
Exit Sub
Finally
End Try

xmlblas = Nothing
Dim evt As EventLog
evt.WriteEntry("SampleService", _XMLFilePath.ToString &
"Loaded to SQL SERVER Successfully")
End Sub
Jul 21 '05 #1
0 1304

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
3
by: Von Shean | last post by:
I am trying to user Bulk loader component in asp.net. The code runs perfectly fine in a test harness but gives the following error when used in a strong named dll called from asp.net using c#. The...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
0
by: Ansu | last post by:
Hi All, I am trying to use SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class to upload XML Documents to SQL server's Database Table. The moment I made it as a service I created and started a new Apartment...
2
by: Tom Richtr | last post by:
I have problem with bulk load in my asp.net website. On my local computer everything works perfectly, while running on server it stops and writes back some error which makes me crazy: Unable to...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.