M
Matthias Kwiedor
Hello!
My Application is Multi-Threaded, where i have several threads which get
datas and write them to the database, or have to read from the database
to compare the datas and make updates if needed.
The Database is MS Access.
Connection String:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb
I open the connection in the main routine
private OleDbConnection OleConn;
public OleDbConnection _strDatabase
{
get
{
if (OleConn == null)
{
try
{
OleConn = new OleDbConnection(strConnstring);
OleConn.Open();
}
}
return (OleConn);
}
}
Then i have a own dll where i have the write and read function included
and call it with "using" statement, the own writen dispose members don't
close the connection to the database (or did dispose do this automatic?)
Everything runs fine, but when i have 3 or more Threads running on the
same time i get sometimes the ole exception "ExecuteReader needs an open
and usable Connection. Current Connectionstatus: Open, Executing" and
the routine will get no datas back.
I included lock(this) into everything which calls up routines to read or
write to the database, only have lock(this) arround the read and write
function had no luck and produces much more errors like the above one.
I can do a workaround by opening the connection everytime i have a read
or write access. That works fine (no errors at all, even with large
amount of Threads), but i needs much more time to do all the database
stuff.
Any Help would be great
Regards
Matthias
My Application is Multi-Threaded, where i have several threads which get
datas and write them to the database, or have to read from the database
to compare the datas and make updates if needed.
The Database is MS Access.
Connection String:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb
I open the connection in the main routine
private OleDbConnection OleConn;
public OleDbConnection _strDatabase
{
get
{
if (OleConn == null)
{
try
{
OleConn = new OleDbConnection(strConnstring);
OleConn.Open();
}
}
return (OleConn);
}
}
Then i have a own dll where i have the write and read function included
and call it with "using" statement, the own writen dispose members don't
close the connection to the database (or did dispose do this automatic?)
Everything runs fine, but when i have 3 or more Threads running on the
same time i get sometimes the ole exception "ExecuteReader needs an open
and usable Connection. Current Connectionstatus: Open, Executing" and
the routine will get no datas back.
I included lock(this) into everything which calls up routines to read or
write to the database, only have lock(this) arround the read and write
function had no luck and produces much more errors like the above one.
I can do a workaround by opening the connection everytime i have a read
or write access. That works fine (no errors at all, even with large
amount of Threads), but i needs much more time to do all the database
stuff.
Any Help would be great
Regards
Matthias