473,769 Members | 4,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error "Operation is not allowed when the object is closed"

The following ASP code yields the following error, but actually the new
record is stored
in database. The same error happens when the application deletes a record,
such as
sqlStmt ="delete from test where username='2323' " Any ideas? Thanks!

<%
Dim objRS, sqlStmt
Set objRS = Server.CreateOb ject ("ADODB.Records et")
sqlStmt = "insert into test VALUES ('2341', '2341');"
objRS.Open sqlStmt, strConnect
objRS.Close
Set objRS = Nothing
%>

ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.

Jul 19 '05 #1
6 46910
An action statement (INSERT, UPDATE, DELETE) does not return any records,
hence you can't close an non-open recordset. Instead, you cn do:

<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
objConn.Open strConnection

objConn.Execute (sqlStmt)

objConn.Close
Set objConn = Nothing
%>

Also, you should not use a connection string in the .Open method of a
recordset object, as this defeats connection pooling:

http://support.microsoft.com/?id=191572

Cheers
Ken

"Matthew Louden" <jr********@hot mail.com> wrote in message
news:eO******** ******@TK2MSFTN GP12.phx.gbl...
: The following ASP code yields the following error, but actually the new
: record is stored
: in database. The same error happens when the application deletes a record,
: such as
: sqlStmt ="delete from test where username='2323' " Any ideas? Thanks!
:
: <%
: Dim objRS, sqlStmt
: Set objRS = Server.CreateOb ject ("ADODB.Records et")
: sqlStmt = "insert into test VALUES ('2341', '2341');"
: objRS.Open sqlStmt, strConnect
: objRS.Close
: Set objRS = Nothing
: %>
:
: ADODB.Recordset error '800a0e78'
: Operation is not allowed when the object is closed.
:
:
:
:
:
Jul 19 '05 #2
Thanks Ken,

I just tried it, but it yields another error on line
objConn.Execute (sqlStmt)
Microsoft OLE DB Provider for SQL Server error '80040e2f'

'runners.dbo.Us er' ???, 'user_level' ?? NULL ?? ??? ? ????. ??? null? ??? ?
????. INSERT?(?) ??????.

any ideas??

"Ken Schaefer" <ke*******@THIS adOpenStatic.co m> wrote in message
news:OJ******** ******@TK2MSFTN GP09.phx.gbl...
An action statement (INSERT, UPDATE, DELETE) does not return any records,
hence you can't close an non-open recordset. Instead, you cn do:

<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
objConn.Open strConnection

objConn.Execute (sqlStmt)

objConn.Close
Set objConn = Nothing
%>

Also, you should not use a connection string in the .Open method of a
recordset object, as this defeats connection pooling:

http://support.microsoft.com/?id=191572

Cheers
Ken

"Matthew Louden" <jr********@hot mail.com> wrote in message
news:eO******** ******@TK2MSFTN GP12.phx.gbl...
: The following ASP code yields the following error, but actually the new
: record is stored
: in database. The same error happens when the application deletes a record, : such as
: sqlStmt ="delete from test where username='2323' " Any ideas? Thanks!
:
: <%
: Dim objRS, sqlStmt
: Set objRS = Server.CreateOb ject ("ADODB.Records et")
: sqlStmt = "insert into test VALUES ('2341', '2341');"
: objRS.Open sqlStmt, strConnect
: objRS.Close
: Set objRS = Nothing
: %>
:
: ADODB.Recordset error '800a0e78'
: Operation is not allowed when the object is closed.
:
:
:
:
:

Jul 19 '05 #3
I got the run-time error: Microsoft OLE DB Provider for SQL Server error
'80040e2f'

I read this http://www.aspfaq.com/show.asp?id=2370, but I am adding a
record, not deleting a record. Since I migrate the whole web pages and
database from one machine to another machine, it worked everything fine in
the old machine. I already changed the connection string, and necessary
links, but the logic should be unchanged.

Please advise! Thanks!
"Ken Schaefer" <ke*******@THIS adOpenStatic.co m> wrote in message
news:OJ******** ******@TK2MSFTN GP09.phx.gbl...
An action statement (INSERT, UPDATE, DELETE) does not return any records,
hence you can't close an non-open recordset. Instead, you cn do:

<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
objConn.Open strConnection

objConn.Execute (sqlStmt)

objConn.Close
Set objConn = Nothing
%>

Also, you should not use a connection string in the .Open method of a
recordset object, as this defeats connection pooling:

http://support.microsoft.com/?id=191572

Cheers
Ken

"Matthew Louden" <jr********@hot mail.com> wrote in message
news:eO******** ******@TK2MSFTN GP12.phx.gbl...
: The following ASP code yields the following error, but actually the new
: record is stored
: in database. The same error happens when the application deletes a record, : such as
: sqlStmt ="delete from test where username='2323' " Any ideas? Thanks!
:
: <%
: Dim objRS, sqlStmt
: Set objRS = Server.CreateOb ject ("ADODB.Records et")
: sqlStmt = "insert into test VALUES ('2341', '2341');"
: objRS.Open sqlStmt, strConnect
: objRS.Close
: Set objRS = Nothing
: %>
:
: ADODB.Recordset error '800a0e78'
: Operation is not allowed when the object is closed.
:
:
:
:
:

Jul 19 '05 #4
Please show your revised code. we're not mind readers.

Matthew Louden wrote:
I got the run-time error: Microsoft OLE DB Provider for SQL Server
error '80040e2f'

I read this http://www.aspfaq.com/show.asp?id=2370, but I am adding a
record, not deleting a record. Since I migrate the whole web pages and
database from one machine to another machine, it worked everything
fine in the old machine. I already changed the connection string, and
necessary links, but the logic should be unchanged.

Please advise! Thanks!
"Ken Schaefer" <ke*******@THIS adOpenStatic.co m> wrote in message
news:OJ******** ******@TK2MSFTN GP09.phx.gbl...
An action statement (INSERT, UPDATE, DELETE) does not return any
records, hence you can't close an non-open recordset. Instead, you
cn do:

<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
objConn.Open strConnection

objConn.Execute (sqlStmt)

objConn.Close
Set objConn = Nothing
%>

Also, you should not use a connection string in the .Open method of a
recordset object, as this defeats connection pooling:

http://support.microsoft.com/?id=191572

Cheers
Ken

"Matthew Louden" <jr********@hot mail.com> wrote in message
news:eO******** ******@TK2MSFTN GP12.phx.gbl...
The following ASP code yields the following error, but actually the
new record is stored
in database. The same error happens when the application deletes a
record, such as
sqlStmt ="delete from test where username='2323' " Any ideas?
Thanks!

<%
Dim objRS, sqlStmt
Set objRS = Server.CreateOb ject ("ADODB.Records et")
sqlStmt = "insert into test VALUES ('2341', '2341');"
objRS.Open sqlStmt, strConnect
objRS.Close
Set objRS = Nothing
%>

ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.


Jul 19 '05 #5
I got the run-time error: Microsoft OLE DB Provider for SQL Server error
'80040e2f' on line
conn.Execute(In sertUsersSql)

Here's the code fragment:
<%
Set conn = Server.CreateOb ject ("ADODB.Connect ion")
conn.Open strConnect
InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
Response.Write InsertUsersSql
conn.Execute(In sertUsersSql)
conn.Close
Set conn = Nothing
%>

I read this http://www.aspfaq.com/show.asp?id=2370, but I am adding a
record, not deleting a record. Any ideas??

"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:OB******** ******@TK2MSFTN GP09.phx.gbl...
Please show your revised code. we're not mind readers.

Matthew Louden wrote:
I got the run-time error: Microsoft OLE DB Provider for SQL Server
error '80040e2f'

I read this http://www.aspfaq.com/show.asp?id=2370, but I am adding a
record, not deleting a record. Since I migrate the whole web pages and
database from one machine to another machine, it worked everything
fine in the old machine. I already changed the connection string, and
necessary links, but the logic should be unchanged.

Please advise! Thanks!
"Ken Schaefer" <ke*******@THIS adOpenStatic.co m> wrote in message
news:OJ******** ******@TK2MSFTN GP09.phx.gbl...
An action statement (INSERT, UPDATE, DELETE) does not return any
records, hence you can't close an non-open recordset. Instead, you
cn do:

<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
objConn.Open strConnection

objConn.Execute (sqlStmt)

objConn.Close
Set objConn = Nothing
%>

Also, you should not use a connection string in the .Open method of a
recordset object, as this defeats connection pooling:

http://support.microsoft.com/?id=191572

Cheers
Ken

"Matthew Louden" <jr********@hot mail.com> wrote in message
news:eO******** ******@TK2MSFTN GP12.phx.gbl...
The following ASP code yields the following error, but actually the
new record is stored
in database. The same error happens when the application deletes a
record, such as
sqlStmt ="delete from test where username='2323' " Any ideas?
Thanks!

<%
Dim objRS, sqlStmt
Set objRS = Server.CreateOb ject ("ADODB.Records et")
sqlStmt = "insert into test VALUES ('2341', '2341');"
objRS.Open sqlStmt, strConnect
objRS.Close
Set objRS = Nothing
%>

ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.


Jul 19 '05 #6
What columns do you have in the table Users? If there are more than two,
then do:

InsertUsersSql = _
"INSERT INTO Users (field1, field2) & _
"VALUES ('myusername', 'mypassword');"

(changing field1, and field2 to be the names of the fields you want the
values inserted into)

Cheers
Ken
"Matthew Louden" <jr********@hot mail.com> wrote in message
news:e$******** ******@TK2MSFTN GP09.phx.gbl...
: I got the run-time error: Microsoft OLE DB Provider for SQL Server error
: '80040e2f' on line
: conn.Execute(In sertUsersSql)
:
: Here's the code fragment:
: <%
: Set conn = Server.CreateOb ject ("ADODB.Connect ion")
: conn.Open strConnect
: InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
: Response.Write InsertUsersSql
: conn.Execute(In sertUsersSql)
: conn.Close
: Set conn = Nothing
: %>
:
: I read this http://www.aspfaq.com/show.asp?id=2370, but I am adding a
: record, not deleting a record. Any ideas??
:
: "Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
: news:OB******** ******@TK2MSFTN GP09.phx.gbl...
: > Please show your revised code. we're not mind readers.
: >
: > Matthew Louden wrote:
: > > I got the run-time error: Microsoft OLE DB Provider for SQL Server
: > > error '80040e2f'
: > >
: > > I read this http://www.aspfaq.com/show.asp?id=2370, but I am adding a
: > > record, not deleting a record. Since I migrate the whole web pages and
: > > database from one machine to another machine, it worked everything
: > > fine in the old machine. I already changed the connection string, and
: > > necessary links, but the logic should be unchanged.
: > >
: > > Please advise! Thanks!
: > >
: > >
: > > "Ken Schaefer" <ke*******@THIS adOpenStatic.co m> wrote in message
: > > news:OJ******** ******@TK2MSFTN GP09.phx.gbl...
: > >> An action statement (INSERT, UPDATE, DELETE) does not return any
: > >> records, hence you can't close an non-open recordset. Instead, you
: > >> cn do:
: > >>
: > >> <%
: > >> Set objConn = Server.CreateOb ject("ADODB.Con nection")
: > >> objConn.Open strConnection
: > >>
: > >> objConn.Execute (sqlStmt)
: > >>
: > >> objConn.Close
: > >> Set objConn = Nothing
: > >> %>
: > >>
: > >> Also, you should not use a connection string in the .Open method of a
: > >> recordset object, as this defeats connection pooling:
: > >>
: > >> http://support.microsoft.com/?id=191572
: > >>
: > >> Cheers
: > >> Ken
: > >>
: > >> "Matthew Louden" <jr********@hot mail.com> wrote in message
: > >> news:eO******** ******@TK2MSFTN GP12.phx.gbl...
: > >>> The following ASP code yields the following error, but actually the
: > >>> new record is stored
: > >>> in database. The same error happens when the application deletes a
: > >>> record, such as
: > >>> sqlStmt ="delete from test where username='2323' " Any ideas?
: > >>> Thanks!
: > >>>
: > >>> <%
: > >>> Dim objRS, sqlStmt
: > >>> Set objRS = Server.CreateOb ject ("ADODB.Records et")
: > >>> sqlStmt = "insert into test VALUES ('2341', '2341');"
: > >>> objRS.Open sqlStmt, strConnect
: > >>> objRS.Close
: > >>> Set objRS = Nothing
: > >>> %>
: > >>>
: > >>> ADODB.Recordset error '800a0e78'
: > >>> Operation is not allowed when the object is closed.
: >
: >
: >
:
:
Jul 19 '05 #7

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

Similar topics

2
5558
by: Dave | last post by:
These code generates the error: WebRequest request = WebRequest.Create("http://www.yahoo.com"); WebResponse response = request.GetResponse(); Here is the stack trace for the error: WebException: The underlying connection was closed: Unable to connect to the remote server.] System.Net.HttpWebRequest.CheckFinalStatus() +673
5
6132
by: D Witherspoon | last post by:
I use the following code to open up a form. ------------------------------------------------------- If fImage Is Nothing Then fImage = New frmImage End If fImage.Show()
4
2167
by: David Cho | last post by:
Hi, this is just plain strange. This is my code. HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.yahoo.com"); request.Method = "POST"; request.ContentType = "text/xml"; StreamWriter sw = new StreamWriter(request.GetRequestStream()); //error occurs here
0
2630
by: lpinho | last post by:
Hi There, I've generated a C# file from a wsdl file using wsdl.exe utility. Then I created a console application and made a call to the method generated, first I got the error: "The request failed with HTTP status 407: Proxy Access Denied." Then I added a proxy validating and proxy credentials and got this:
0
1461
by: Jens Kreier | last post by:
Hello everybody! I got a problem with a nearly undocumented (maybe-)bug in the WebClient class. Anyways the problem is as follows: When I try to work with the simple WebClient.DownloadFile(URL) function everything works fine as long as I download static HTML-pages. As soon as I try to get the content of a remote ASP page nothing works and I get a WebException as mentioned in the subject.
3
1909
by: Ravindra Tripathi | last post by:
Hi I have a form with a textbox and a close button. whenever I try to close the the form i get an exception "cannot access disposed object named" how do i correct this issue? Ravindra
0
1677
by: Steve | last post by:
Hi!, I'm using WebRequest to post a URL. But, sometimes, this tell me the error "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.". I don't know why!!. This worked perfect in .NET 1.1, but in .NET 2.0, I has this behavior. Thanks!
12
2049
by: spibou | last post by:
Why is a pointer allowed to point to one position past the end of an array but not to one position before the beginning of an array ? Is there any reason why the former is more useful than the later ? Spiros Bousbouras
2
5194
by: semedao | last post by:
Hi , someone know the reason and how to handle it? thanks
7
4845
by: EManning | last post by:
Using A2003. I'm receiving this error when returning from a "DoCmd.OpenReport..." statement. I have a tab control with a subform on every tab. The user selects an item from a combobox at the top of the main form which refreshes all the subforms. If this DoCmd statement is not executed, then I don't receive the error. I tried a "DoCmd.OpenQuery..." instead of a report but get the same error. I want the user to be able to...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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,...
0
10208
Oralloy
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...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9855
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
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, 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...
1
7404
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 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...
0
6662
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();...
1
3952
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 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.