Results 1 to 5 of 5

Thread: ExecuteNonQuery halts thread

  1. #1

    Thread Starter
    Junior Member Cakkie's Avatar
    Join Date
    May 2002
    Location
    Olen, Belgium
    Posts
    24

    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
    Tom Cannaerts
    www.tom.be

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  3. #3

    Thread Starter
    Junior Member Cakkie's Avatar
    Join Date
    May 2002
    Location
    Olen, Belgium
    Posts
    24
    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.
    Tom Cannaerts
    www.tom.be

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5

    Thread Starter
    Junior Member Cakkie's Avatar
    Join Date
    May 2002
    Location
    Olen, Belgium
    Posts
    24
    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
    Tom Cannaerts
    www.tom.be

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width