473,385 Members | 1,630 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,385 software developers and data experts.

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.CreateObject ("ADODB.Recordset")
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 46841
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.CreateObject("ADODB.Connection")
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********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.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.CreateObject ("ADODB.Recordset")
: 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.User' ???, 'user_level' ?? NULL ?? ??? ? ????. ??? null? ??? ?
????. INSERT?(?) ??????.

any ideas??

"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:OJ**************@TK2MSFTNGP09.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.CreateObject("ADODB.Connection")
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********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.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.CreateObject ("ADODB.Recordset")
: 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*******@THISadOpenStatic.com> wrote in message
news:OJ**************@TK2MSFTNGP09.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.CreateObject("ADODB.Connection")
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********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.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.CreateObject ("ADODB.Recordset")
: 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*******@THISadOpenStatic.com> wrote in message
news:OJ**************@TK2MSFTNGP09.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.CreateObject("ADODB.Connection")
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********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.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.CreateObject ("ADODB.Recordset")
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(InsertUsersSql)

Here's the code fragment:
<%
Set conn = Server.CreateObject ("ADODB.Connection")
conn.Open strConnect
InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
Response.Write InsertUsersSql
conn.Execute(InsertUsersSql)
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******@NOyahoo.SPAMcom> wrote in message
news:OB**************@TK2MSFTNGP09.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*******@THISadOpenStatic.com> wrote in message
news:OJ**************@TK2MSFTNGP09.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.CreateObject("ADODB.Connection")
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********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP12.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.CreateObject ("ADODB.Recordset")
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********@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
: I got the run-time error: Microsoft OLE DB Provider for SQL Server error
: '80040e2f' on line
: conn.Execute(InsertUsersSql)
:
: Here's the code fragment:
: <%
: Set conn = Server.CreateObject ("ADODB.Connection")
: conn.Open strConnect
: InsertUsersSql= "Insert Into Users VALUES ('myusername', 'mypassword');"
: Response.Write InsertUsersSql
: conn.Execute(InsertUsersSql)
: 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******@NOyahoo.SPAMcom> wrote in message
: news:OB**************@TK2MSFTNGP09.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*******@THISadOpenStatic.com> wrote in message
: > > news:OJ**************@TK2MSFTNGP09.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.CreateObject("ADODB.Connection")
: > >> 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********@hotmail.com> wrote in message
: > >> news:eO**************@TK2MSFTNGP12.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.CreateObject ("ADODB.Recordset")
: > >>> 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
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: ...
5
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
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 =...
0
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...
0
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...
3
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
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...
12
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...
2
by: semedao | last post by:
Hi , someone know the reason and how to handle it? thanks
7
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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...

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.