|
-
Dec 10th, 2002, 03:04 PM
#1
Thread Starter
Junior Member
ExecuteNonQuery halts thread
I'm calling the ExecuteNonQuery method of a oledbcommand object. This is done in a class module which runs it's own thread.
When I call the method, the thread seems to freeze, sleep, disappear whatever. The execution never get's to the next line.
Errorhandlers aren't firing either.
Anyone know what could cause this? And How do I solve this?
Code:
Dim DBCmd As New OleDb.OleDbCommand()
Dim Sql As String
Sql = "INSERT INTO ....."
DBCmd.CommandText = Sql
DBCmd.Connection = SYS_DBMails ' open OledbConnection
Try
Dim iRecs As Integer
iRecs = DBCmd.ExecuteNonQuery() ' "freezes" here
Catch ex As Exception
Dim s As String = ex.ToString
End Try
-
Dec 10th, 2002, 03:07 PM
#2
Is the connection in the same thread also? Or is it created in the main thread and referenced in the other.
Last edited by Edneeis; Dec 10th, 2002 at 03:11 PM.
-
Dec 10th, 2002, 03:13 PM
#3
Thread Starter
Junior Member
Nope. The connection is a public object in a module (not a class). The connection is opened by the main application thread, in another class.
-
Dec 10th, 2002, 03:37 PM
#4
Could that be the trouble? Some kind of marshaling problem with the connection. Try opening a new connection in the new thread and see if it still hangs.
-
Dec 10th, 2002, 03:41 PM
#5
Thread Starter
Junior Member
Hmm, appearantly ADO.Net doesn't respond that well to multithreading...
This is what I've done...
Code:
Dim DBCnn = New OleDbConnection(SYS_DBCnn.Connectionstring)
DBCnn.Open
...
DBCmd.Connection = DBCnn
DBCmd.ExecuteNonQuery()
...and it works.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|