473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ConnectionState problem - managing connections to an Access database

Hi,

I have an asp.net application which runs from a CD-ROM using Cassini. As
such, it is single user only.

The application connects to an Access database when it is loaded, and
keeps the same connection open all the time (as it's single user, this
shouldn't be a problem).

There is logic in the code to ensure that the connection is
automatically opened the first time it is used and the connection is
stored in an Application variable:

if ((cmd.Connection.State == ConnectionState.Closed) ||
(cmd.Connection.State == ConnectionState.Broken)) cmd.Connection.Open();

However occasionally while testing my application under IIS, it comes up
with this error message:

System.InvalidOperationException:
The connection is already Open (state=Connecting).

Or this:

ExecuteReader requires an open and available Connection. The
connection's current state is Open, Executing.

But if the state is Connecting, you can neither call .Open nor can you
execute a query. So how can I maintain an open connection without these
errors occuring?

I don't understand why it is ever in the "Exectuting"
state in a single user application. Is it because IIS is multithreaded
and perhaps it's using two+ threads to host my application?

If so, how can I stop these errors from happening? I don't want to open
and close a new connection each time I do something because this is too
slow (40ms) and some pages require 100 queries for reasons I don't have
time to explain here. Using a single connection - the application
performs very well but has these errors. Is there a way I can get the
best of both worlds?

Someone suggested that I disable connection pooling but this made no
difference.

Thanks,

Nick...
--
Please reply to the newsgroup or I won't see your message.
Nov 19 '05 #1
14 4774
Hi Nick,

I understand that you may think it is better to use a single Connection, but
you're really trying to make an end-run around the .Net database Connection
model. The .Net platform is designed to make efficient use of database
Connections, and to reuse them all by itself. it does this by the process of
Connection Pooling.

You may be confusing the Connection Class and a database Connection. In
fact, they are not the same. A Connection class is a class that provides a
programming interface for working with database Connections. A database
Connection is a software entity that contains data about the daabase
Connection (that is, the client app and the database), and process for
communicating between the client app and the database. This is an important
distinction to make. Why? Because in the .Net platform, closing a Connection
doesn't actuall kill a database Connection. It disconnects the Connection
class from the database Connection itself, which is held in a Connection
Pool for re-use by any Connection class that has the same Connection String.

In other words, by persisting your Connection (class), you're not
accomplishing anything that the .Net platform doesn't do all by itself
already, which is to persist actual database Connections. And, in fact, you
are, as I said earlier, making an expensive end-run around the .Net database
Connection model, which is more likely to cause problems than it is to solve
any (as you have seen).

Therefore, I would recommend that you take Microsoft's word for how the .Net
platform works, and use it as prescribed by Microsoft. That is, create your
Connection classes when and where you need them, and close and/or dispose
them as quickly as possible, in order to avoid the sorts of problems you're
experiencing right now.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Nick Gilbert" <Ni***@newsgroup.nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I have an asp.net application which runs from a CD-ROM using Cassini. As
such, it is single user only.

The application connects to an Access database when it is loaded, and
keeps the same connection open all the time (as it's single user, this
shouldn't be a problem).

There is logic in the code to ensure that the connection is
automatically opened the first time it is used and the connection is
stored in an Application variable:

if ((cmd.Connection.State == ConnectionState.Closed) ||
(cmd.Connection.State == ConnectionState.Broken)) cmd.Connection.Open();

However occasionally while testing my application under IIS, it comes up
with this error message:

System.InvalidOperationException:
The connection is already Open (state=Connecting).

Or this:

ExecuteReader requires an open and available Connection. The
connection's current state is Open, Executing.

But if the state is Connecting, you can neither call .Open nor can you
execute a query. So how can I maintain an open connection without these
errors occuring?

I don't understand why it is ever in the "Exectuting"
state in a single user application. Is it because IIS is multithreaded
and perhaps it's using two+ threads to host my application?

If so, how can I stop these errors from happening? I don't want to open
and close a new connection each time I do something because this is too
slow (40ms) and some pages require 100 queries for reasons I don't have
time to explain here. Using a single connection - the application
performs very well but has these errors. Is there a way I can get the
best of both worlds?

Someone suggested that I disable connection pooling but this made no
difference.

Thanks,

Nick...
--
Please reply to the newsgroup or I won't see your message.

Nov 19 '05 #2
> In other words, by persisting your Connection (class), you're not
accomplishing anything that the .Net platform doesn't do all by itself
already, which is to persist actual database Connections.


If this is the case, why do I get a 5000% performance improvement if I
cache my connection class? Why also does calling .Open take about 30ms
to execute each time you call it if it's not really having to open the
database connection again?

If you don't belive me - try it yourself. Calling Connection.Open about
2000 times on SQL Server takes almost no time. On Access it takes
several seconds. Perhaps you're assuming .NET handles Access connections
in the same way it handles SQL Server connections?

Calling .Open every time I call a query makes some of my pages unusably
slow - whereas currently they render in a fraction of a second. I could
either rewrite the page so it uses fewer queries (not very feasable for
my project) or try and fix this bug another way.

Nick...
Nov 19 '05 #3
Not using Access myself but according to
http://msdn.microsoft.com/library/de...taprovider.asp
and other sources, my understanding is that pooling should work as this is
handled by the provider.

What is the format of the Jet DB ? (Access 97, 2000, 2003 level ?) Do you
see the same slowness on a read/write device ?

I'll likely give this a try. Just curious to know if pooling works or not
with Jet... For example an interesting test would be to try to disable
pooling. If it's the same this is that pooling doesn't work. If it's slower,
this is because the original slow result comes from something else than
pooling (permissions checking or whatever else)...

--
Patrice

"Nick Gilbert" <Ni***@newsgroup.nospam> a écrit dans le message de
news:eq**************@TK2MSFTNGP09.phx.gbl...
In other words, by persisting your Connection (class), you're not
accomplishing anything that the .Net platform doesn't do all by itself
already, which is to persist actual database Connections.


If this is the case, why do I get a 5000% performance improvement if I
cache my connection class? Why also does calling .Open take about 30ms
to execute each time you call it if it's not really having to open the
database connection again?

If you don't belive me - try it yourself. Calling Connection.Open about
2000 times on SQL Server takes almost no time. On Access it takes
several seconds. Perhaps you're assuming .NET handles Access connections
in the same way it handles SQL Server connections?

Calling .Open every time I call a query makes some of my pages unusably
slow - whereas currently they render in a fraction of a second. I could
either rewrite the page so it uses fewer queries (not very feasable for
my project) or try and fix this bug another way.

Nick...

Nov 19 '05 #4
Ok it looks actually that the problem is that pooling is not enabled by
default for Jet (or perhaps depending on the OS or whatever ???)

What I saw here :
- with a basic connection string, creating/closing 100 connections took
around 4 s.
- surprisingly it made no difference when disabling pooling.
- I tested then to see what happens when explictely enabling pooling and it
gave a much better 0,1 s result

For now, it looks like to me that pooling is actually disabled by default
(at least on a workstation OS ???).

You could then try to see what it gives if you don't cache the connection
and enable pooling (by adding "OLE DB Services=-1" in the connection
string).

Let us know what you find...

--
Patrice
"Patrice" <no****@nowhere.com> a écrit dans le message de
news:Oa**************@TK2MSFTNGP10.phx.gbl...
Not using Access myself but according to
http://msdn.microsoft.com/library/de...taprovider.asp and other sources, my understanding is that pooling should work as this is
handled by the provider.

What is the format of the Jet DB ? (Access 97, 2000, 2003 level ?) Do you
see the same slowness on a read/write device ?

I'll likely give this a try. Just curious to know if pooling works or not
with Jet... For example an interesting test would be to try to disable
pooling. If it's the same this is that pooling doesn't work. If it's slower, this is because the original slow result comes from something else than
pooling (permissions checking or whatever else)...

--
Patrice

"Nick Gilbert" <Ni***@newsgroup.nospam> a écrit dans le message de
news:eq**************@TK2MSFTNGP09.phx.gbl...
In other words, by persisting your Connection (class), you're not
accomplishing anything that the .Net platform doesn't do all by itself
already, which is to persist actual database Connections.


If this is the case, why do I get a 5000% performance improvement if I
cache my connection class? Why also does calling .Open take about 30ms
to execute each time you call it if it's not really having to open the
database connection again?

If you don't belive me - try it yourself. Calling Connection.Open about
2000 times on SQL Server takes almost no time. On Access it takes
several seconds. Perhaps you're assuming .NET handles Access connections
in the same way it handles SQL Server connections?

Calling .Open every time I call a query makes some of my pages unusably
slow - whereas currently they render in a fraction of a second. I could
either rewrite the page so it uses fewer queries (not very feasable for
my project) or try and fix this bug another way.

Nick...


Nov 19 '05 #5
Patrice wrote:
Ok it looks actually that the problem is that pooling is not enabled by
default for Jet (or perhaps depending on the OS or whatever ???)

What I saw here :
- with a basic connection string, creating/closing 100 connections took
around 4 s.
- surprisingly it made no difference when disabling pooling.
- I tested then to see what happens when explictely enabling pooling and it
gave a much better 0,1 s result

For now, it looks like to me that pooling is actually disabled by default
(at least on a workstation OS ???).

You could then try to see what it gives if you don't cache the connection
and enable pooling (by adding "OLE DB Services=-1" in the connection
string).

Let us know what you find...


You're right.

The reason it was so slow was that connection pooling seems to be
disabled by default. Adding "OLE DB Services=-1" to my connection string
has speeded up the appliction by an order of magnitude (no wonder
disabling it didn't make any difference!). So I've removed all my
connection caching code and now the bug has gone as as well! Thanks
Patrice! An average page in my application now loads in 0.10s instead of
0.90s and my slow loading 4 second pages load in less than 0.5s. I can't
complain about a 10 fold performance improvement just by adding
something to a connection string.

The only thing that worries me is *WHY* is it disabled by default if it
provides so much performance improvement? It seems to be working for me,
but what if it's disabled by default because there are issues with it?

Oh well - I'll just have to see if any arise.

Nick...
Nov 19 '05 #6
My first though would be it depends on the OS (connection pooling would make
more sense on an server OS rather than a workstation OS).

From
http://msdn.microsoft.com/library/de...l/pooling2.asp
and though this is not directly related (ODBC) :
Enabling Connection Pooling
For Internet Information Services (IIS) version 3.0, pooling is set to off
by default, so you need to manually turn on connection pooling. For IIS
version 4.0 and later, pooling has been set to on by default. (IIS 3.0 uses
ODBC 3.0, and IIS 4.0 uses ODBC 3.5.) If you are coding by using the ActiveX
Data Objects (ADO) object model to the OLE DB Provider for ODBC (MSDASQL),
connection pooling will be turned on for you. If you are not using ADO and
are coding directly to the ODBC API, you will need to turn on pooling
yourself.

Though not directly related, it would me make think from a general point of
view that it is better to explicitely ask for the behavior you depend on
rather than to rely on some kind of default (that could vary in time)...

--

Patrice
"Nick Gilbert" <Ni***@newsgroup.nospam> a écrit dans le message de
news:Os****************@TK2MSFTNGP14.phx.gbl...
Patrice wrote:
Ok it looks actually that the problem is that pooling is not enabled by
default for Jet (or perhaps depending on the OS or whatever ???)

What I saw here :
- with a basic connection string, creating/closing 100 connections took
around 4 s.
- surprisingly it made no difference when disabling pooling.
- I tested then to see what happens when explictely enabling pooling and it gave a much better 0,1 s result

For now, it looks like to me that pooling is actually disabled by default (at least on a workstation OS ???).

You could then try to see what it gives if you don't cache the connection and enable pooling (by adding "OLE DB Services=-1" in the connection
string).

Let us know what you find...


You're right.

The reason it was so slow was that connection pooling seems to be
disabled by default. Adding "OLE DB Services=-1" to my connection string
has speeded up the appliction by an order of magnitude (no wonder
disabling it didn't make any difference!). So I've removed all my
connection caching code and now the bug has gone as as well! Thanks
Patrice! An average page in my application now loads in 0.10s instead of
0.90s and my slow loading 4 second pages load in less than 0.5s. I can't
complain about a 10 fold performance improvement just by adding
something to a connection string.

The only thing that worries me is *WHY* is it disabled by default if it
provides so much performance improvement? It seems to be working for me,
but what if it's disabled by default because there are issues with it?

Oh well - I'll just have to see if any arise.

Nick...

Nov 19 '05 #7
Patrice,

For anyone around here who survived the Window NT days, you would have
experienced the joy of debugging connection pooling problems (which of
course, was enabled by default, back then). On multiple CPU's, under
moderate stress, it worked horribly. Thanks to our brave efforts,
Microsoft, in their wisdom, now disables it by default and it is a far more
stable and predictable sub-system. MDAC 2.61 on Windows 2000 was the first
release where it actually worked predictably and correctly.

That's a battle I won't soon forget ... as I write this from my padded room
;-)

Ad.

"Patrice" <no****@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
My first though would be it depends on the OS (connection pooling would
make
more sense on an server OS rather than a workstation OS).

From
http://msdn.microsoft.com/library/de...l/pooling2.asp
and though this is not directly related (ODBC) :
Enabling Connection Pooling
For Internet Information Services (IIS) version 3.0, pooling is set to off
by default, so you need to manually turn on connection pooling. For IIS
version 4.0 and later, pooling has been set to on by default. (IIS 3.0
uses
ODBC 3.0, and IIS 4.0 uses ODBC 3.5.) If you are coding by using the
ActiveX
Data Objects (ADO) object model to the OLE DB Provider for ODBC (MSDASQL),
connection pooling will be turned on for you. If you are not using ADO and
are coding directly to the ODBC API, you will need to turn on pooling
yourself.

Though not directly related, it would me make think from a general point
of
view that it is better to explicitely ask for the behavior you depend on
rather than to rely on some kind of default (that could vary in time)...

--

Patrice
"Nick Gilbert" <Ni***@newsgroup.nospam> a écrit dans le message de
news:Os****************@TK2MSFTNGP14.phx.gbl...
Patrice wrote:
> Ok it looks actually that the problem is that pooling is not enabled by
> default for Jet (or perhaps depending on the OS or whatever ???)
>
> What I saw here :
> - with a basic connection string, creating/closing 100 connections took
> around 4 s.
> - surprisingly it made no difference when disabling pooling.
> - I tested then to see what happens when explictely enabling pooling
> and it > gave a much better 0,1 s result
>
> For now, it looks like to me that pooling is actually disabled by default > (at least on a workstation OS ???).
>
> You could then try to see what it gives if you don't cache the connection > and enable pooling (by adding "OLE DB Services=-1" in the connection
> string).
>
> Let us know what you find...


You're right.

The reason it was so slow was that connection pooling seems to be
disabled by default. Adding "OLE DB Services=-1" to my connection string
has speeded up the appliction by an order of magnitude (no wonder
disabling it didn't make any difference!). So I've removed all my
connection caching code and now the bug has gone as as well! Thanks
Patrice! An average page in my application now loads in 0.10s instead of
0.90s and my slow loading 4 second pages load in less than 0.5s. I can't
complain about a 10 fold performance improvement just by adding
something to a connection string.

The only thing that worries me is *WHY* is it disabled by default if it
provides so much performance improvement? It seems to be working for me,
but what if it's disabled by default because there are issues with it?

Oh well - I'll just have to see if any arise.

Nick...


Nov 19 '05 #8
I promise. I won't ask Microsoft to enable this by default dismissing your
past efforts ;-)

Actually they done the same thing with Windows Server 2003 (disabling all by
default). Got the big picture now ;-)

Patrice

--

"Adrian Moore" <qu***********@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
Patrice,

For anyone around here who survived the Window NT days, you would have
experienced the joy of debugging connection pooling problems (which of
course, was enabled by default, back then). On multiple CPU's, under
moderate stress, it worked horribly. Thanks to our brave efforts,
Microsoft, in their wisdom, now disables it by default and it is a far more stable and predictable sub-system. MDAC 2.61 on Windows 2000 was the first release where it actually worked predictably and correctly.

That's a battle I won't soon forget ... as I write this from my padded room ;-)

Ad.

"Patrice" <no****@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
My first though would be it depends on the OS (connection pooling would
make
more sense on an server OS rather than a workstation OS).

From
http://msdn.microsoft.com/library/de...l/pooling2.asp and though this is not directly related (ODBC) :
Enabling Connection Pooling
For Internet Information Services (IIS) version 3.0, pooling is set to off by default, so you need to manually turn on connection pooling. For IIS
version 4.0 and later, pooling has been set to on by default. (IIS 3.0
uses
ODBC 3.0, and IIS 4.0 uses ODBC 3.5.) If you are coding by using the
ActiveX
Data Objects (ADO) object model to the OLE DB Provider for ODBC (MSDASQL), connection pooling will be turned on for you. If you are not using ADO and are coding directly to the ODBC API, you will need to turn on pooling
yourself.

Though not directly related, it would me make think from a general point
of
view that it is better to explicitely ask for the behavior you depend on
rather than to rely on some kind of default (that could vary in time)...

--

Patrice
"Nick Gilbert" <Ni***@newsgroup.nospam> a écrit dans le message de
news:Os****************@TK2MSFTNGP14.phx.gbl...
Patrice wrote:
> Ok it looks actually that the problem is that pooling is not enabled by > default for Jet (or perhaps depending on the OS or whatever ???)
>
> What I saw here :
> - with a basic connection string, creating/closing 100 connections took > around 4 s.
> - surprisingly it made no difference when disabling pooling.
> - I tested then to see what happens when explictely enabling pooling
> and

it
> gave a much better 0,1 s result
>
> For now, it looks like to me that pooling is actually disabled by

default
> (at least on a workstation OS ???).
>
> You could then try to see what it gives if you don't cache the

connection
> and enable pooling (by adding "OLE DB Services=-1" in the connection
> string).
>
> Let us know what you find...

You're right.

The reason it was so slow was that connection pooling seems to be
disabled by default. Adding "OLE DB Services=-1" to my connection string has speeded up the appliction by an order of magnitude (no wonder
disabling it didn't make any difference!). So I've removed all my
connection caching code and now the bug has gone as as well! Thanks
Patrice! An average page in my application now loads in 0.10s instead of 0.90s and my slow loading 4 second pages load in less than 0.5s. I can't complain about a 10 fold performance improvement just by adding
something to a connection string.

The only thing that worries me is *WHY* is it disabled by default if it
provides so much performance improvement? It seems to be working for me, but what if it's disabled by default because there are issues with it?

Oh well - I'll just have to see if any arise.

Nick...



Nov 19 '05 #9
>> You could then try to see what it gives if you don't cache the connection
and enable pooling (by adding "OLE DB Services=-1" in the connection
string).

Let us know what you find...


You're right.

The reason it was so slow was that connection pooling seems to be
disabled by default. Adding "OLE DB Services=-1" to my connection string
has speeded up the appliction by an order of magnitude (no wonder
disabling it didn't make any difference!). So I've removed all my
connection caching code and now the bug has gone as as well! Thanks
Patrice! An average page in my application now loads in 0.10s instead of
0.90s and my slow loading 4 second pages load in less than 0.5s. I can't
complain about a 10 fold performance improvement just by adding
something to a connection string.

The only thing that worries me is *WHY* is it disabled by default if it
provides so much performance improvement? It seems to be working for me,
but what if it's disabled by default because there are issues with it?

Oh well - I'll just have to see if any arise.


Follow-up: Connection pooling does not seem to work reliably in Access
and I have had to turn it off.

For example, I had some code that updated a value in a database and then
immediately requested a dataset which contained that value. Sometimes I
noticed that the new dataset still contained an OLD value, even though
the database shows the correct value. Ie Jet was sending back an out of
date value for the data.

Similarly when updating, I occasionally get the following exception:

"The Microsoft Jet database engine stopped the process because you and
another user are attempting to change the same data at the same time. ".

This is in a single threaded application with only one user.

I'm coming to the conclusion that connection pooling in access doesn't
work or is horribly bugged. The odd thing is, I can only reproduce this
error easily on one machine. On my machine it seems fine - but it may
just be because it's a faster machine or perhaps my machine has newer
drivers that have fixed this problem. How can I find out which version
of the OleDb drivers each machine is using?

The big problem I now have, is that without connection pooling, my
application is really slow! GRRR.

Thanks,

Nick...
Nov 19 '05 #10
It's not connection pooling. It's JET. JET does not write to the disk file
until it's bored (idle). As long as there is activity (adding more rows,
selecting, changing), it does not flush its local cache to the disk. This
helps query performance. If you open a Transaction and perform the changes
it forces JET to write immediately, but then your interactive performance
goes into the gutter.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Nick Gilbert" <Ni***@newsgroup.nospam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You could then try to see what it gives if you don't cache the
connection
and enable pooling (by adding "OLE DB Services=-1" in the connection
string).

Let us know what you find...


You're right.

The reason it was so slow was that connection pooling seems to be
disabled by default. Adding "OLE DB Services=-1" to my connection string
has speeded up the appliction by an order of magnitude (no wonder
disabling it didn't make any difference!). So I've removed all my
connection caching code and now the bug has gone as as well! Thanks
Patrice! An average page in my application now loads in 0.10s instead of
0.90s and my slow loading 4 second pages load in less than 0.5s. I can't
complain about a 10 fold performance improvement just by adding
something to a connection string.

The only thing that worries me is *WHY* is it disabled by default if it
provides so much performance improvement? It seems to be working for me,
but what if it's disabled by default because there are issues with it?

Oh well - I'll just have to see if any arise.


Follow-up: Connection pooling does not seem to work reliably in Access
and I have had to turn it off.

For example, I had some code that updated a value in a database and then
immediately requested a dataset which contained that value. Sometimes I
noticed that the new dataset still contained an OLD value, even though
the database shows the correct value. Ie Jet was sending back an out of
date value for the data.

Similarly when updating, I occasionally get the following exception:

"The Microsoft Jet database engine stopped the process because you and
another user are attempting to change the same data at the same time. ".

This is in a single threaded application with only one user.

I'm coming to the conclusion that connection pooling in access doesn't
work or is horribly bugged. The odd thing is, I can only reproduce this
error easily on one machine. On my machine it seems fine - but it may
just be because it's a faster machine or perhaps my machine has newer
drivers that have fixed this problem. How can I find out which version
of the OleDb drivers each machine is using?

The big problem I now have, is that without connection pooling, my
application is really slow! GRRR.

Thanks,

Nick...

Nov 19 '05 #11
William (Bill) Vaughn wrote:
It's not connection pooling. It's JET. JET does not write to the disk file
until it's bored (idle). As long as there is activity (adding more rows,
selecting, changing), it does not flush its local cache to the disk. This
helps query performance. If you open a Transaction and perform the changes
it forces JET to write immediately, but then your interactive performance
goes into the gutter.


How easy is it to do a transaction from .NET? Or is it something you
have to do inside Access using a module?

Are there any other workarounds to this problem? Eg somehow disabling
the write cache or forcing it to write immediately for certain queries?

It's odd that the bug seems to go away when I disable connection
pooling, but perhaps the delay of opening a new connection is enough to
prevent the error from occuring (or maybe it always flushes the cache
when closing a connection).

Thanks,

Nick...
Nov 19 '05 #12
William (Bill) Vaughn wrote:
It's not connection pooling. It's JET. JET does not write to the disk file
until it's bored (idle). As long as there is activity (adding more rows,
selecting, changing), it does not flush its local cache to the disk. This
helps query performance. If you open a Transaction and perform the changes
it forces JET to write immediately, but then your interactive performance
goes into the gutter.


I've tried wrapping the code in a transaction but the problem still
occurs. It seems that transactions don't affect this problem at all.

It just seems that occasionally access (or perhaps IIS) gives me back
data that is now obsolete.

Nick..
Nov 19 '05 #13
Nick Gilbert wrote:
William (Bill) Vaughn wrote:
It's not connection pooling. It's JET. JET does not write to the disk file
until it's bored (idle). As long as there is activity (adding more rows,
selecting, changing), it does not flush its local cache to the disk. This
helps query performance. If you open a Transaction and perform the changes
it forces JET to write immediately, but then your interactive performance
goes into the gutter.


I've tried wrapping the code in a transaction but the problem still
occurs. It seems that transactions don't affect this problem at all.

It just seems that occasionally access (or perhaps IIS) gives me back
data that is now obsolete.


I've done some more testing and I've narrowed down the problem a bit
more. It seems that if you immediately read back the data on the same
connection, it appears to be correct. But if, after updating the data,
you redirect to a webpage which should contain the updated data, then it
somehow can get OLD data. This happens even when the code is wrapped in
a transaction as recommended by William above.

I presume what's happening is that if you redirect to a different page
after updating the database, you don't necessarily get the same thread
in IIS or the same connection from the connection pool, and somehow it's
managing to retrieve the old value from the database or perhaps some
caching is happening somewhere at IIS level.

I've proved that IIS isn't serving me an old *page* but IS serving me
old *data* by adding a sequential counter to the page (if it was serving
me an old page the counter would go backwards). So the problem is that
Access or it's drivers is returning the old values for some of the rows.

I really need to fix this problem ASAP. Any help would be greatly
appreciated.

Nick...
Nov 19 '05 #14
Well, I missed the fact that you're trying to use JET in an ASP environment.
While this is possible, as you have discovered there are a litany of issues
that pop up. JET was never designed to be used as a database engine to
support a web site. It's designed to handle a single "human" user and
perhaps share a database file over the intranet. When you read-back from a
JET database, it tries to use its local cache. This might be why you read a
record just written but others cannot. I think you're beating a dead horse.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Nick Gilbert" <Ni***@newsgroup.nospam> wrote in message
news:Or****************@TK2MSFTNGP09.phx.gbl...
William (Bill) Vaughn wrote:
It's not connection pooling. It's JET. JET does not write to the disk
file
until it's bored (idle). As long as there is activity (adding more rows,
selecting, changing), it does not flush its local cache to the disk. This
helps query performance. If you open a Transaction and perform the
changes
it forces JET to write immediately, but then your interactive performance
goes into the gutter.


How easy is it to do a transaction from .NET? Or is it something you
have to do inside Access using a module?

Are there any other workarounds to this problem? Eg somehow disabling
the write cache or forcing it to write immediately for certain queries?

It's odd that the bug seems to go away when I disable connection
pooling, but perhaps the delay of opening a new connection is enough to
prevent the error from occuring (or maybe it always flushes the cache
when closing a connection).

Thanks,

Nick...

Nov 19 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: MAB71 | last post by:
There should be a way to copy an access database ( .mdb file ) without closing connections to it. Unfortunately the FileCopy statement in VB gives an error if users are connected to the db. But I...
5
by: premmehrotra | last post by:
I currently have a multi-user access database which is put on a shared drive L: on a Windows Servers. Entire database is one file premdb.mdb. Users access this database from their laptops....
5
by: XFER | last post by:
Does anyone know how well 10 concurrent users will perform on the above config? Are there any known issues, limits to using MS Access with IIS 5 and ASP.net on a non- ..net server (NT)? thanks.
9
by: Nathan Sokalski | last post by:
I am trying to connect to a Microsoft Access Database from my ASP.NET Application. I use the following code to create my connection string: cmdSelect.Connection = New...
5
by: Seok Bee | last post by:
Dear Experts, I currently trying to use the FileUpload control from asp.net 2.0 to upload files. The uploading of the file I would like to store it in the Access Database. Unfortunately, I've no...
17
by: shineofleo | last post by:
Here is the situation: I wrote a VB programm, which stores all the information in a single Access database file using jet engine. It worked well, however one of my customs reported that there was...
1
by: Rameel | last post by:
Friends, I'm probably being more critical with VB.Net Windows application. I have Developed VisualStudio 20005 VB.Net Windows application how willl i be able to save a specific record into my...
5
by: John | last post by:
I have an ASP.NET 2.0 application developed in VB.net, that accesses an Microsoft Access database. When the database is on the same IIS server all works just fine. BUT when it tried to access the...
0
by: SL Culby | last post by:
Hello everyone, I have a project where I pull SQL Server data put it into a dataset and now I have to put the dataset data into an Access Database. The dataset currently is over 2000 row, so looping...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.