Unspecified error on Database Connection in Multiple Threads

J

Jerry Spence1

I am starting up a number of threads. Each one specifies a connection to the
same database.

Sub ReaderThread()

Dim cn As New System.Data.OleDb.OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dbaseFile
cn.Open()

etc...

After the 65th thread starts up I get the error:

{System.Data.OleDb.OleDbException}
[System.Data.OleDb.OleDbException]: {System.Data.OleDb.OleDbException}
HelpLink: Nothing
InnerException: Nothing
Message: "Unspecified error"
Source: "Microsoft JET Database Engine"
StackTrace: " at
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at EDAC_DataLogger.Form1.ReaderThread() in C:\Company\xxxxxxxxxx
DataLogger Form1 V1.1.vb:line 212"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The error on line 212 is the cn.Open() command. I don't know if there is
something significant about opening 65 connections. If I do 64 threads it
all runs OK.

-Jerry
 
W

W.G. Ryan eMVP

Jerry:

connection objects aren't Thread Safe. I can't tell what's going on just
from this - but it should blow up pretty quickly. When are you sending
Command objects through?

However, I just say that on GP - I'm guessing the connection pool is full on
the Access DB. Please tell me that you aren't seriously trying to open > 5
connections to an access DB?
 
J

Jerry Spence1

Yes I am (or was). Each single connection was through a different thread.
Because you can only have one Datareader open I had to define a seperate
connection for each thread which was a pain (whereas I did have the
connection as public). There could be a large number of threads generated
(100 up).

Since posting this I have found the answer. There is a restriction of 64
connections on a database. I have now managed to sych the threads so that I
close some before opening too many.

Thanks for your help.

-Jerry

W.G. Ryan eMVP said:
Jerry:

connection objects aren't Thread Safe. I can't tell what's going on just
from this - but it should blow up pretty quickly. When are you sending
Command objects through?

However, I just say that on GP - I'm guessing the connection pool is full on
the Access DB. Please tell me that you aren't seriously trying to open > 5
connections to an access DB?

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
Jerry Spence1 said:
I am starting up a number of threads. Each one specifies a connection to the
same database.

Sub ReaderThread()

Dim cn As New System.Data.OleDb.OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dbaseFile
cn.Open()

etc...

After the 65th thread starts up I get the error:

{System.Data.OleDb.OleDbException}
[System.Data.OleDb.OleDbException]: {System.Data.OleDb.OleDbException}
HelpLink: Nothing
InnerException: Nothing
Message: "Unspecified error"
Source: "Microsoft JET Database Engine"
StackTrace: " at
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at EDAC_DataLogger.Form1.ReaderThread() in C:\Company\xxxxxxxxxx
DataLogger Form1 V1.1.vb:line 212"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The error on line 212 is the cn.Open() command. I don't know if there is
something significant about opening 65 connections. If I do 64 threads it
all runs OK.

-Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top