473,473 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1309

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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.