Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Formatting error (ASP)
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

tane
Starting Member

2 Posts

Posted - 23 April 2007 :  08:15:33  Show Profile
Hi Folks,
I'm trying to make both these actions to work in the same page but am getting errors (The connection cannot be used to perform this operation. It is either closed or invalid in this context.).
I think this must just be a formatting issue since they both work if I delete the other one out. If anyone could help I would really appreciate it.

Many Thanks
Tane


<%
Dim rsPPPN
Set rsPPPN=Server.CreateObject("ADODB.Recordset")
rsPPPN.Open "SELECT * FROM TBL_STUDENTS WHERE USER_ID='"&user_name&"' AND ACCESS_ID=1",conn,1,2
If rsPPPN.EOF then
rsPPPN.Close
Response.Redirect "default.asp"
end if
conn.Close
Set rsPPPN=Nothing
Set conn=Nothing
%>

<%

Set rsPPPN=Server.CreateObject("ADODB.Recordset")
rsPPPN.Open "SELECT * FROM TBL_CHAPS WHERE USER_ID='"&user_name&"' AND CHAPTER_NO=02",conn,1,2
If rsPPPN.EOF then
rsPPPN.Close
Response.Redirect "chapter2.asp"
End If
conn.Close
Set rsPPPN=Nothing
Set conn=Nothing
%>

chrishirst
Starting Member

United Kingdom
2 Posts

Posted - 23 April 2007 :  16:49:44  Show Profile  Visit chrishirst's Homepage
You destroy the connection object (set conn = Nothing) in the first segment then try to use it again

Indifference will be the downfall of Mankind, but who cares
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 24 April 2007 :  08:46:29  Show Profile  Send pdrg a Yahoo! Message
Chrishirst is correct - you can safely remove all the orange lines (and get a free performance boost too)

<%
Dim rsPPPN
Set rsPPPN=Server.CreateObject("ADODB.Recordset")
rsPPPN.Open "SELECT * FROM TBL_STUDENTS WHERE USER_ID='"&user_name&"' AND ACCESS_ID=1",conn,1,2
If rsPPPN.EOF then
rsPPPN.Close
Response.Redirect "default.asp"
end if
conn.Close
Set rsPPPN=Nothing
Set conn=Nothing

%>

<%

Set rsPPPN=Server.CreateObject("ADODB.Recordset")
rsPPPN.Open "SELECT * FROM TBL_CHAPS WHERE USER_ID='"&user_name&"' AND CHAPTER_NO=02",conn,1,2
If rsPPPN.EOF then
rsPPPN.Close
Response.Redirect "chapter2.asp"
End If
conn.Close
Set rsPPPN=Nothing
Set conn=Nothing
%>
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 24 April 2007 :  08:49:13  Show Profile
You'll need to remove the first conn.Close, as well.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 24 April 2007 :  12:48:56  Show Profile  Send pdrg a Yahoo! Message
Ahhh - yep, what Shaggy says. He the rokxx

<%
Dim rsPPPN
Set rsPPPN=Server.CreateObject("ADODB.Recordset")
rsPPPN.Open "SELECT * FROM TBL_STUDENTS WHERE USER_ID='"&user_name&"' AND ACCESS_ID=1",conn,1,2
If rsPPPN.EOF then
rsPPPN.Close
Response.Redirect "default.asp"
end if
conn.Close
Set rsPPPN=Nothing
Set conn=Nothing

%>

<%

Set rsPPPN=Server.CreateObject("ADODB.Recordset")
rsPPPN.Open "SELECT * FROM TBL_CHAPS WHERE USER_ID='"&user_name&"' AND CHAPTER_NO=02",conn,1,2
If rsPPPN.EOF then
rsPPPN.Close
Response.Redirect "chapter2.asp"
End If
conn.Close
Set rsPPPN=Nothing
Set conn=Nothing
%>

Edited by - pdrg on 24 April 2007 12:50:37
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07