This topic is locked

Connection error

3/9/2004 8:17:36 AM
ASPRunnerPro General questions
author

Hi,
The goal is to not allow the person to go to the Report page if they haven't been

assisgned any locations yet. Reports is a menu item in the website. Can you see what I am missing or referencing wrong? I use ASP Runner 2.4. There is no other code I as using this is all of it. Everything I read says that I have something out of place i.e. opening before set or vice verssa, or I named something wrong but I cannot see it. I enclosed the dbconnection code as well so you can see it.
Thanks,

Bandit
' This is the error that is thrown
ADODB.Recordset error '800a0e7d'
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
/Filter.asp, line 14
/////// My Code //////
<!--#include file="include/dbconnection.asp"-->
<!-- dbconnection.asp is as follows:
<%

strConnection = "Provider=MSDataShape;DRIVER={Microsoft Access Driver (.mdb)};DBQ=" & server.mappath("some.mdb") & ";UID=;PWD="

%>

-->
<%

' filter user

username=Session("User")
' open database connection

Set rs = server.CreateObject ("ADODB.Recordset")

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

' set SQL statement

strSQL = "Select Count(
) From qryLocations where MR= '" & username & "' "

'this is the line that causes the error

rs.Open strSQL

' execute SQL statement

dbConnection.Execute strSQL

' run test

if rs.EOF then

%>

<script>

alert('No locations have been assigned to you. Please contact the office.');

</script>

<%

else

response.redirect "Report_list.asp"

end if

' close recordset and database connection

rs.close

dbConnection.close

%>
///// end my code ///////
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=439&image=1&table=forumtopics' class='bbc_emoticon' alt=':huh:' />

Admin 3/10/2004

This code is incorrect:

rs.Open strSQL

' execute SQL statement

dbConnection.Execute strSQL


try to replace it with this one:

rs.Open strSQL , dbConnection