Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 19th, 2005, 03:07 PM
sarak1015 sarak1015 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 sarak1015 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 14 sec
Reputation Power: 0
Unhappy "Operation is not allowed when the object is closed" error

Hi,

I'm getting the error "Operation is not allowed when the object is closed" from the code at the end of this message.
The really funny thing is that the operation in question is objRSInsert.close, and I'm pretty sure I haven't
already closed it. Any ideas?

Thanks,

Sara

Const adOpenDynamic = 2
Const adLockBatchOptimistic = 4
Const adCmdText = &H0001
Dim objConn, objRSInsert, strSQLInsert, strAuthorname, strAuthorid, strAuthaffil, strAuthoremail
strAuthorname = Request.QueryString("authorname")
strAuthorid = Request.QueryString("authorid")
strAuthaffil = Request.QueryString("authaffil")
strAuthoremail = Request.QueryString("authemail")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRSInsert = Server.CreateObject("ADODB.Recordset")
strSQLInsert = "INSERT INTO tblAuthor (author_id, author_name, author_affiliation, author_email) "
strSQLInsert = strSQLInsert & "VALUES (" & "'" & strAuthorid & "', " & "'" & strAuthorname & "', "
strSQLInsert = strSQLInsert & "'" & strAuthaffil & "', " & "'" & strAuthoremail & "')"
objRSInsert.Open strSQLInsert, objConn, adOpenDynamic, adLockBatchOptimistic, adCmdText
Response.Write "The author has been added to the database.<br />"
Response.Write strAuthorid & " " & strAuthorname & ", " & strAuthaffil & ", " & strAuthoremail
objRSInsert.Close
Set objRSInsert = Nothing
objConn.Close
Set objConn = Nothing

Reply With Quote
  #2  
Old March 19th, 2005, 05:07 PM
ProEdge's Avatar
ProEdge ProEdge is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Somewhere I belong
Posts: 1,565 ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level)ProEdge User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 7 m 15 sec
Reputation Power: 39
I'm not familiar with this error but I searched Operation is not allowed when the object is closed in Google and found some pages. Here's one from the Microsoft website. You might want to do a search for this error on Google because I see a lot of resources.
Comments on this post
sarak1015 disagrees!
__________________
Keep it Prodigy, Keep it Real

Reply With Quote
  #3  
Old March 19th, 2005, 06:26 PM
lewy's Avatar
lewy lewy is offline
Alter Ego Wizard
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Edinburg Tx
Posts: 4,381 lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)lewy User rank is General 8th Grade (Above 100000 Reputation Level)  Folding Points: 1009 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 1 Day 23 h 7 m 43 sec
Reputation Power: 1488
Use the following for your code:
Code:
 Dim objConn, objRSInsert, strSQLInsert, strAuthorname, strAuthorid, strAuthaffil, strAuthoremail
 
   strAuthorname = Request.QueryString("authorname")
   strAuthorid = Request.QueryString("authorid")
   strAuthaffil = Request.QueryString("authaffil")
   strAuthoremail = Request.QueryString("authemail")
 
   Set objConn = Server.CreateObject("ADODB.Connection")
    DBPath = Server.MapPath( "YourDbName.mdb" )
 
    'open the db with the driver you're using
    'you may change it to match your needs, if it's not this one reply back
    objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
 	 
   'build the SQL statement
   strSQLInsert = "INSERT INTO tblAuthor (author_id, author_name, author_affiliation, author_email) "
   strSQLInsert = strSQLInsert & "VALUES (" & "'" & strAuthorid & "', " & "'" & strAuthorname & "', "
   strSQLInsert = strSQLInsert & "'" & strAuthaffil & "', " & "'" & strAuthoremail & "')"
   
   objConn.Execute(strSQLInsert)
 
   'write proper message for the user
   Response.Write "The author has been added to the database.<br />"
   Response.Write strAuthorid & " " & strAuthorname & ", " & strAuthaffil & ", " & strAuthoremail
 
   'reclaim system resources
   objConn.Close
   Set objConn = Nothing
 

Not sure why you're trying to use the code thru a recordset.
Recordsets should only be used when you need to go thru db records.
For insertion the above code should work.
Comments on this post
sarak1015 disagrees!
__________________
................... ASCII and ye shall receive ..................
Knowledge is the only resource on earth that multiplies when shared


Support the Shemzilla Project
Powered by C#

Reply With Quote
  #4  
Old March 19th, 2005, 07:13 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
As lewy showed you can accomplish this very easily.

Example:
Code:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnect

strSQLInsert = "INSERT INTO tblAuthor (author_id, author_name, author_affiliation, author_email) "
strSQLInsert = strSQLInsert & "VALUES (" & "'" & strAuthorid & "', " & "'" & strAuthorname & "', "
strSQLInsert = strSQLInsert & "'" & strAuthaffil & "', " & "'" & strAuthoremail & "')"

Conn.Execute(strSQLInsert)

Conn.Close
Set Conn = Nothing
Comments on this post
sarak1015 disagrees!

Reply With Quote
  #5  
Old April 6th, 2005, 12:09 PM
sarak1015 sarak1015 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 sarak1015 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 14 sec
Reputation Power: 0
Smile Thanks!

I'm a newbie, so your help is greatly appreciated!

Quote:
Originally Posted by lewy
Use the following for your code:
Code:
 Dim objConn, objRSInsert, strSQLInsert, strAuthorname, strAuthorid, strAuthaffil, strAuthoremail
 
strAuthorname = Request.QueryString("authorname")
strAuthorid = Request.QueryString("authorid")
strAuthaffil = Request.QueryString("authaffil")
strAuthoremail = Request.QueryString("authemail")
 
Set objConn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath( "YourDbName.mdb" )
 
'open the db with the driver you're using
'you may change it to match your needs, if it's not this one reply back
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
 
'build the SQL statement
strSQLInsert = "INSERT INTO tblAuthor (author_id, author_name, author_affiliation, author_email) "
strSQLInsert = strSQLInsert & "VALUES (" & "'" & strAuthorid & "', " & "'" & strAuthorname & "', "
strSQLInsert = strSQLInsert & "'" & strAuthaffil & "', " & "'" & strAuthoremail & "')"
 
objConn.Execute(strSQLInsert)
 
'write proper message for the user
Response.Write "The author has been added to the database.<br />"
Response.Write strAuthorid & " " & strAuthorname & ", " & strAuthaffil & ", " & strAuthoremail
 
'reclaim system resources
objConn.Close
Set objConn = Nothing

Not sure why you're trying to use the code thru a recordset.
Recordsets should only be used when you need to go thru db records.
For insertion the above code should work.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > "Operation is not allowed when the object is closed" error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT