473,406 Members | 2,293 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,406 software developers and data experts.

Database closing problem

Hi

I have a vb.net app that opens an access database runs several sql action
queries on the tables and closes the db. This is done every few minutes. The
problem is that sometimes I get an error 'ExecuteNonQuery requires an open
and available Connection. The connection's current state is closed'. My
question is; is there a situation where an app automatically closes the db
connection causing this error and is there a way to prevent this?

Thanks

Regards
May 3 '07 #1
6 2222
On May 3, 11:55 am, "John" <J...@nospam.infovis.co.ukwrote:
Hi

I have a vb.net app that opens an access database runs several sql action
queries on the tables and closes the db. This is done every few minutes. The
problem is that sometimes I get an error 'ExecuteNonQuery requires an open
and available Connection. The connection's current state is closed'. My
question is; is there a situation where an app automatically closes the db
connection causing this error and is there a way to prevent this?

Thanks

Regards
I'm guessing you are trying to use a global connection object right?

If so, change the code to open a connection to the database, execute
your commands, and then close/dispose of the command and connection.
You should try to avoid using a "global" connection object at all
costs as it can lead to serious problems (with very few benefits). If
I guessed wrong, please post your code so I can take a look.

Thanks,

Seth Rowe
May 3 '07 #2
Hi Seth

It is true that I am opening a global connection. Executing only some of sql
queries will cause problem with the integrity of the data in the database.
By using a global connection I was hoping to provide a guaranteed connection
to all queries reducing any expected problems. Is there a way to ensure that
all queries get executed or none?

Thanks

Regards

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
On May 3, 11:55 am, "John" <J...@nospam.infovis.co.ukwrote:
>Hi

I have a vb.net app that opens an access database runs several sql action
queries on the tables and closes the db. This is done every few minutes.
The
problem is that sometimes I get an error 'ExecuteNonQuery requires an
open
and available Connection. The connection's current state is closed'. My
question is; is there a situation where an app automatically closes the
db
connection causing this error and is there a way to prevent this?

Thanks

Regards

I'm guessing you are trying to use a global connection object right?

If so, change the code to open a connection to the database, execute
your commands, and then close/dispose of the command and connection.
You should try to avoid using a "global" connection object at all
costs as it can lead to serious problems (with very few benefits). If
I guessed wrong, please post your code so I can take a look.

Thanks,

Seth Rowe


May 3 '07 #3
Is there a way to ensure that all queries get executed or none?
>
Follow the advice of Seth

Cor

"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:ua**************@TK2MSFTNGP05.phx.gbl...
Hi Seth

It is true that I am opening a global connection. Executing only some of
sql queries will cause problem with the integrity of the data in the
database. By using a global connection I was hoping to provide a
guaranteed connection to all queries reducing any expected problems. Is
there a way to ensure that all queries get executed or none?

Thanks

Regards

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
>On May 3, 11:55 am, "John" <J...@nospam.infovis.co.ukwrote:
>>Hi

I have a vb.net app that opens an access database runs several sql
action
queries on the tables and closes the db. This is done every few minutes.
The
problem is that sometimes I get an error 'ExecuteNonQuery requires an
open
and available Connection. The connection's current state is closed'. My
question is; is there a situation where an app automatically closes the
db
connection causing this error and is there a way to prevent this?

Thanks

Regards

I'm guessing you are trying to use a global connection object right?

If so, change the code to open a connection to the database, execute
your commands, and then close/dispose of the command and connection.
You should try to avoid using a "global" connection object at all
costs as it can lead to serious problems (with very few benefits). If
I guessed wrong, please post your code so I can take a look.

Thanks,

Seth Rowe



May 4 '07 #4
CORRECTION!

Seth is full of crap
Take your egocentric way of living and shove it up your ass

in ADO classic, we used to be able to open a connection; and close a
connection-- we used to be able to have multiple recordsets on the
same connection

now all we got is bloatware

We used to be able to run ADO commands FROM THE CLIENTSIDE OF THE WEB
BROWSER
this is no longer possible

screw ADO.net

\
On May 3, 9:46 am, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On May 3, 11:55 am, "John" <J...@nospam.infovis.co.ukwrote:
Hi
I have a vb.net app that opens an access database runs several sql action
queries on the tables and closes the db. This is done every few minutes. The
problem is that sometimes I get an error 'ExecuteNonQuery requires an open
and available Connection. The connection's current state is closed'. My
question is; is there a situation where an app automatically closes the db
connection causing this error and is there a way to prevent this?
Thanks
Regards

I'm guessing you are trying to use a global connection object right?

If so, change the code to open a connection to the database, execute
your commands, and then close/dispose of the command and connection.
You should try to avoid using a "global" connection object at all
costs as it can lead to serious problems (with very few benefits). If
I guessed wrong, please post your code so I can take a look.

Thanks,

Seth Rowe

May 4 '07 #5
Cor;

stfu and make microsoft fix the BUG


On May 3, 10:28 pm, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Is there a way to ensure that all queries get executed or none?

Follow the advice of Seth

Cor

"John" <J...@nospam.infovis.co.ukschreef in berichtnews:ua**************@TK2MSFTNGP05.phx.gbl. ..
Hi Seth
It is true that I am opening a global connection. Executing only some of
sql queries will cause problem with the integrity of the data in the
database. By using a global connection I was hoping to provide a
guaranteed connection to all queries reducing any expected problems. Is
there a way to ensure that all queries get executed or none?
Thanks
Regards
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
On May 3, 11:55 am, "John" <J...@nospam.infovis.co.ukwrote:
Hi
>I have a vb.net app that opens an access database runs several sql
action
queries on the tables and closes the db. This is done every few minutes.
The
problem is that sometimes I get an error 'ExecuteNonQuery requires an
open
and available Connection. The connection's current state is closed'. My
question is; is there a situation where an app automatically closes the
db
connection causing this error and is there a way to prevent this?
>Thanks
>Regards
I'm guessing you are trying to use a global connection object right?
If so, change the code to open a connection to the database, execute
your commands, and then close/dispose of the command and connection.
You should try to avoid using a "global" connection object at all
costs as it can lead to serious problems (with very few benefits). If
I guessed wrong, please post your code so I can take a look.
Thanks,
Seth Rowe- Hide quoted text -

- Show quoted text -

May 4 '07 #6
On Thu, 3 May 2007 18:53:27 +0100, "John" <Jo**@nospam.infovis.co.uk>
wrote:
>Hi Seth

It is true that I am opening a global connection. Executing only some of sql
queries will cause problem with the integrity of the data in the database.
By using a global connection I was hoping to provide a guaranteed connection
to all queries reducing any expected problems. Is there a way to ensure that
all queries get executed or none?
Use a proper database?

google: "ado.net transactions"
May 13 '07 #7

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

Similar topics

4
by: dustin lee | last post by:
Over the years I've gotten out of the habit of explicitly closing file objects (whether for reading or writing) since the right thing always seems to happen auto-magically (e.g. files get written...
0
by: MC | last post by:
Hi! I have noticed this strange problem I cannot explain when I connect to sql server using .net: I use a .NET app to connect to a sql server database. When I do so, two strange things...
7
by: Graham Taylor | last post by:
I've tried posting this in the 'microsoft.public.access' but I will post it here also, as I think it might be the webserver which is causing my problem. --------- I have an Access 2003 database...
7
by: Medved | last post by:
Hi, We have not a smallest access database (30 tables, 160 queries,35 forms,40 reports,15 pages) with some links to other databases and some sql queries from other databases.The databse is not...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
5
by: nick_faye | last post by:
Hi, I am still a newbie to VB and using MS Access 2000. I am currently trying to provide a preview of reports before printing them. My program is simple: AC.DoCmd.OpenReport "MyReport",...
2
by: nicole | last post by:
I have a problem. In two cases the access database is closing completely (but leaves the .ldb file behind.). I just added a new form and now when I switch from the design view to the preview via...
1
by: Vegar Hansen | last post by:
Hello everone. Can somebody help me? When I run my code I can read, write to and delete from database, but when I have done one of these things and try to copy the databasefile from my folder...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
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...

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.