cgibb Level: Guest

|
VB.NET: Adodb Recordsets in a thread Archived to Disk
I am writing a component that will get datafrom a number of different sources and then complile it into to recordset, and return it to the calling application.
Currently, the application that is doing this was written in delphi, as it supported multi-threading, but as only one person in the office knows delphi, and the application is extremely inefficient as it is doing explicit type conversions for every field of every record.
I created a test app, the the method to get the data runs if I just called in from the Main() subroutine, but as soon as I call it in a thread, I get the following error message:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in MultiDBNET.exe
Additional information: Non-NULL controlling IUnknown was specified, and either the requested interface was not
IUnknown, or the provider does not support COM aggregation.
Does anyone know why this is not running in a thread?
I have attached the code if you want to have a look at it.
Thanks very much in advance!!!
----------START OF CODE--------
Imports System.Threading
Imports System.Data
Imports System.Data.OleDb
Module MultiDBNET
Sub Main()
Dim ConnectionString
Dim QueryText
Dim objQuery As QueryDatabase
Dim objThread As Thread
ConnectionString = "provider=FnDBProvider;data source=DefaultIMS:DevImage:FileNet;user id=SysAdmin;password=SysAdmin;Prompt=" & ADODB.ConnectPromptEnum.adPromptNever & ";SystemType=" & idmSysTypeOptions.idmSysTypeIS & ";"
QueryText = "SELECT * from FnDocument Where F_DOCCLASSNAME = 'CCELAAP'"
objQuery = New QueryDatabase()
objQuery.ConnectionString = ConnectionString
objQuery.Query = QueryText
'objQuery.RunQuery() --> using this line instead of the threading commands below works fine!
objThread = New Thread(AddressOf objQuery.RunQuery)
objThread.Start()
objThread.Join()
End Sub
End Module
Public Class QueryDatabase
'This is used to actually execute the query. This is the one that will be run multithreaded.
Public Query As String
Public ConnectionString As String
Dim cnQuery As ADODB.Connection
Dim rsResults As ADODB.Recordset
Public Sub RunQuery()
cnQuery = New ADODB.Connection()
cnQuery.ConnectionString = ConnectionString
cnQuery.Open(ConnectionString, "", "", -1)
rsResults = cnQuery.Execute("Select * from FnDocument Where F_DOCCLASSNAME='CCELAAP'")
MsgBox(rsResults.RecordCount & "Results Returned")
Exit Sub
End Sub
End Class
[Edited by admin on 03-05-2002 at 04:07 PM GMT]
|