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

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 February 24th, 2005, 02:01 AM
okl okl is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Singapore
Posts: 359 okl User rank is Private First Class (20 - 50 Reputation Level)okl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 h 24 m 16 sec
Reputation Power: 5
Send a message via MSN to okl
object open error...cant locate the exact open connection

Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/eass/common/test/2004s1/start_check.asp, line 85


Code:
  <!-- #include file="../../../database/connection.asp" -->
  
  <%
  	dim checkMaxAttempt,checkScore1,checkScore2
  	checkMaxAttempt = 0
  	checkScore1 = 0
  	checkScore2 = 0
  
  	Session("Paper") = "2004S1"
  
  
  	'--------------------------------------------------------------------------
  	' Set the SQL query search for studentID from database
  	'--------------------------------------------------------------------------
 	strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
  	objRst.Open strSQL, objConn
  
  	If objRst.EOF <> FALSE Then ' No attempts record
  
  
  	'--------------------------------------------------------------------------
  	' set them 3 attempts and a new time.
  	'--------------------------------------------------------------------------
  		strSQL = "INSERT INTO Attempts (StudentID,Paper,MaxAttempts,Hrs,Mins,Secs)"
  		strSQL = strSQL & "VALUES"
  		strSQL = strSQL & "('"& Session("StudID") & "',"
  		strSQL = strSQL & "'" & Session("Paper") & "',"
  		strSQL = strSQL & " " & 3 & ","
  		strSQL = strSQL & " " & 2 & ","
  		strSQL = strSQL & " " & 0 & ","
  		strSQL = strSQL & " " & 0 & ")"
  
  		objConn.Execute (strSQL)
  
  
  
  		strSQL = "INSERT INTO 2004S1_Score (StudentID)"
  		strSQL = strSQL & "VALUES"
  		strSQL = strSQL & "('"& Session("StudID") & "')"
  
  		objConn.Execute (strSQL)
  
  
  	Else
  		objRst.Close
  
  		'--------------------------------------------------------------------------
  		' check for score records
  		'--------------------------------------------------------------------------
 		strSQL = "Select * FROM 2004S1_Score WHERE (studentID = '" & Session("StudID") & "')"
  		objRst.Open strSQL, objConn
  
  		checkScore1= objRst("S12004_Score1")
  		checkScore2= objRst("S12004_Score2")
  		objRst.Close
  
  		'--------------------------------------------------------------------------
  		' only allows 2nd and 3rd attempts if only scored less than 70%
  		'--------------------------------------------------------------------------
 		strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
  		objRst.Open strSQL, objConn
  
  		checkMaxAttempt = objRst("MaxAttempts")
  		objRst.Close
  
  		If checkMaxAttempt = "2" AND checkScore1 >= "70" Then
  				response.redirect "error.asp"
  
 		 	ElseIf checkMaxAttempt <= "1" AND checkScore2 >= "70" Then
 					response.redirect "error.asp"
  
 				ElseIf checkMaxAttempt <= "0" Then
 			 		response.redirect "error.asp"
  
  		Else  'do nothing
  		End If
  
  
  	End If
  
  	'--------------------------------------------------------------------------
  	' update # of attempts
  	'--------------------------------------------------------------------------
  	strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
  	objRst.Open strSQL, objConn
  
  	checkMaxAttempt = objRst("MaxAttempts")
  	checkMaxAttempt = checkMaxAttempt - 1
  
  	objRst.close
  	Set objRst = Nothing
  
 	strSQL="Update Attempts SET MaxAttempts = "& checkMaxAttempt &" WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
  	objConn.Execute (strSQL)
  
  
  	objConn.Close
  	Set objConn = Nothing
  
  	response.redirect "q12.asp"
  
  
  %>
  

Reply With Quote
  #2  
Old February 24th, 2005, 02:06 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,193 nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 8 h 39 m 27 sec
Reputation Power: 718
Hi,

your objRst only closes in the Else of the first if is executed, put a objRst.Close, before you create the new recordset

Code:
objRst.Close
strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
objRst.Open strSQL, objConn


Hope this helps
__________________
Look! Its a ShemZilla



Reply With Quote
  #3  
Old February 24th, 2005, 02:20 AM
okl okl is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Singapore
Posts: 359 okl User rank is Private First Class (20 - 50 Reputation Level)okl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 h 24 m 16 sec
Reputation Power: 5
Send a message via MSN to okl
Quote:
Originally Posted by nofriends
Hi,

your objRst only closes in the Else of the first if is executed, put a objRst.Close, before you create the new recordset

Code:
objRst.Close
 strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
 objRst.Open strSQL, objConn


Hope this helps

hi, after closed it , it gave me annother error
  • Error Type:
    ADODB.Recordset (0x800A0E78)
    Operation is not allowed when the object is closed.
    /eass/common/test/2004s1/start_check.asp, line 84




Reply With Quote
  #4  
Old February 24th, 2005, 02:25 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,193 nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 8 h 39 m 27 sec
Reputation Power: 718
Hi, ok delete the previous .Close and put one in your if statement

Code:
 If objRst.EOF <> FALSE Then ' No attempts record
   
   
 	  '--------------------------------------------------------------------------
 	  ' set them 3 attempts and a new time.
 	  '--------------------------------------------------------------------------
 		  strSQL = "INSERT INTO Attempts (StudentID,Paper,MaxAttempts,Hrs,Mins,Secs)"
 		  strSQL = strSQL & "VALUES"
 		  strSQL = strSQL & "('"& Session("StudID") & "',"
 		  strSQL = strSQL & "'" & Session("Paper") & "',"
 		  strSQL = strSQL & " " & 3 & ","
 		  strSQL = strSQL & " " & 2 & ","
 		  strSQL = strSQL & " " & 0 & ","
 		  strSQL = strSQL & " " & 0 & ")"
   
 		  objConn.Execute (strSQL)
   
   
   
 		  strSQL = "INSERT INTO 2004S1_Score (StudentID)"
 		  strSQL = strSQL & "VALUES"
 		  strSQL = strSQL & "('"& Session("StudID") & "')"
   
 		  objConn.Execute (strSQL)
   
 		  objRst.Close
 	  Else
 		  objRst.Close
   
 		  '--------------------------------------------------------------------------
 		  ' check for score records
 		  '--------------------------------------------------------------------------
 		 strSQL = "Select * FROM 2004S1_Score WHERE (studentID = '" & Session("StudID") & "')"
 		  objRst.Open strSQL, objConn
   
 		  checkScore1= objRst("S12004_Score1")
 		  checkScore2= objRst("S12004_Score2")
 		  objRst.Close
   
 		  '--------------------------------------------------------------------------
 		  ' only allows 2nd and 3rd attempts if only scored less than 70%
 		  '--------------------------------------------------------------------------
 		 strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
 		  objRst.Open strSQL, objConn
   
 		  checkMaxAttempt = objRst("MaxAttempts")
 		  objRst.Close
   
 		  If checkMaxAttempt = "2" AND checkScore1 >= "70" Then
 				  response.redirect "error.asp"
   
 			  ElseIf checkMaxAttempt <= "1" AND checkScore2 >= "70" Then
 			 		response.redirect "error.asp"
   
 				 ElseIf checkMaxAttempt <= "0" Then
 			 		 response.redirect "error.asp"
   
 		  Else  'do nothing
 		  End If
   
   
 	  End If
 


hope this helps

Reply With Quote
  #5  
Old February 24th, 2005, 02:31 AM
okl okl is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Location: Singapore
Posts: 359 okl User rank is Private First Class (20 - 50 Reputation Level)okl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 h 24 m 16 sec
Reputation Power: 5
Send a message via MSN to okl
Quote:
Originally Posted by nofriends
Hi, ok delete the previous .Close and put one in your if statement

Code:
  If objRst.EOF <> FALSE Then ' No attempts record
    
    
  	  '--------------------------------------------------------------------------
  	  ' set them 3 attempts and a new time.
  	  '--------------------------------------------------------------------------
  		  strSQL = "INSERT INTO Attempts (StudentID,Paper,MaxAttempts,Hrs,Mins,Secs)"
  		  strSQL = strSQL & "VALUES"
  		  strSQL = strSQL & "('"& Session("StudID") & "',"
  		  strSQL = strSQL & "'" & Session("Paper") & "',"
  		  strSQL = strSQL & " " & 3 & ","
  		  strSQL = strSQL & " " & 2 & ","
  		  strSQL = strSQL & " " & 0 & ","
  		  strSQL = strSQL & " " & 0 & ")"
    
  		  objConn.Execute (strSQL)
    
    
    
  		  strSQL = "INSERT INTO 2004S1_Score (StudentID)"
  		  strSQL = strSQL & "VALUES"
  		  strSQL = strSQL & "('"& Session("StudID") & "')"
    
  		  objConn.Execute (strSQL)
    
  		  objRst.Close
  	  Else
  		  objRst.Close
    
  		  '--------------------------------------------------------------------------
  		  ' check for score records
  		  '--------------------------------------------------------------------------
 		 strSQL = "Select * FROM 2004S1_Score WHERE (studentID = '" & Session("StudID") & "')"
  		  objRst.Open strSQL, objConn
    
  		  checkScore1= objRst("S12004_Score1")
  		  checkScore2= objRst("S12004_Score2")
  		  objRst.Close
    
  		  '--------------------------------------------------------------------------
  		  ' only allows 2nd and 3rd attempts if only scored less than 70%
  		  '--------------------------------------------------------------------------
 		 strSQL = "Select * FROM Attempts WHERE (studentID = '" & Session("StudID") & "') AND (Paper ='"& Session("Paper") &"')"
  		  objRst.Open strSQL, objConn
    
  		  checkMaxAttempt = objRst("MaxAttempts")
  		  objRst.Close
    
  		  If checkMaxAttempt = "2" AND checkScore1 >= "70" Then
  				  response.redirect "error.asp"
    
 			 ElseIf checkMaxAttempt <= "1" AND checkScore2 >= "70" Then
 			 		response.redirect "error.asp"
    
 				 ElseIf checkMaxAttempt <= "0" Then
 			 		 response.redirect "error.asp"
    
  		  Else  'do nothing
  		  End If
    
    
  	  End If
  


hope this helps


thanks it worked!

btw, you should only set objconn.close and set objconn = nothing in the very end of ur asp file if they are few sql insert or update statenment objConn.Execute (strSQL)?


and when u use objrst.close, it is u set objrst = nothing after it immediately or only just need it in the very end of asp file too ?

Reply With Quote
  #6  
Old February 24th, 2005, 02:40 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,193 nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)nofriends User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1Folding Points: 151652 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 8 h 39 m 27 sec
Reputation Power: 718
Well, that is a good question

I would say its good standards to close you rs and conn as soon as you are done with the processing of it.

And at the end of the database interaction, set both of them to nothing.

I don't know if there is a DO and DONT, but one thing is for sure, you have to close your objects when you are done with them, and set them to nothing before you leave the page aswell.

Glad its working now!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > object open error...cant locate the exact open connection


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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





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