I have multiple threads in my application, each which open a connection to a
database as follows:
Sub ReaderThread()
Dim cmd As New OleDbCommand
Dim dr As OleDbDataReader
cmd.Connection = cn
cmd.CommandText = "SELECT * from Mytable"
dr = cmd.ExecuteReader
While dr.Read
'Do something
End While
cmd.dispose()
dr.close
do
'Do lots of things
loop
end sub
I am getting an error saying that "There is already a connection open" which
suggests that a connection on one thread is fighting with a connection on
the other.
Since I am declaring dr and cmd locally I can't work out why I am getting
this error.
-Jerry