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.Connectio n.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.InvalidO perationExcepti on:
The connection is already Open (state=Connecti ng).
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
14 4825
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***@newsgrou p.nospam> wrote in message
news:%2******** ********@tk2msf tngp13.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...
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...
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..
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...
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***@newsgrou p.nospam> wrote in message
news:Or******** ********@TK2MSF TNGP09.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... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 can copy the file using
windows explorer so there must be a way. WinAPI function or something?
I'm using VB6 and Access 2000
|
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. Following problems
occur:
1. Access is way too slow in WAN environment. Server is located in New
Jersey and users are in California and Puerto Rico.
2. Database often becomes corrupt
3. When one user updates some data in the database, other users...
|
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.
|
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
System.Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATASOURCE="
& Server.MapPath("/WebApplication1/nathansokalski_com.mdb"))
Although the error does not occur until the Fill() method is called:
|
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 idea how I can do that. Can anyone provide
me some solution by writing the code in vb.net?
Many thanks in advance.
Regards,
| |
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 some
problems with this programm. I checked, the log files showed that the
database was corrupted.
The customer told me that there no 'illegal' operation such as pull out
the plug, or kill the programm via task manager...
So is there any...
|
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 database file throu GUI Save Record button?
As i write the comand as foloow but it is not inserting the new record in to the Access Database.
Public Function Open_Connection() As Boolean
Try
Select Case...
|
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 same database on a different
server I get a permission error. I've created a shared drive on the
other server and give it permission with all rights, as well as the
Access database. BUT no matter how I set up the connection string in my
app, I...
|
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 through and inserting one row at a time is very expensive. Does anyone know a fast way with low overhead to accomplish this task. I have been working in this direction (code below) however the code inserts 0 rows into the access database.
...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |