Author |
Topic  |
|
tane
Starting Member
2 Posts |
Posted - 23 April 2007 : 08:15:33
|
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
|
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
|
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 24 April 2007 : 08:46:29
|
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 %> |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 24 April 2007 : 08:49:13
|
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.” |
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 24 April 2007 : 12:48:56
|
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 |
 |
|
|
Topic  |
|