Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2004, 03:49 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default Sorting Problems - PLEASE HELP! last resort

I am having a problem sorting my record sets. This is what i have so far, and i get the error listed below whenever i click any of the text header links.

Error:
ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

/sites.asp, line 89

Code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Adminstraive Area - Sites</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
    'Declares Variables
    Dim dbName
    Dim ObjConn
    Dim Admin
    Dim SSort
        SSort = Request.QueryString("Sort")
    Dim BBy
        If Request.QueryString("By") <> "" Then
             BBy = Request.QueryString("By")
        Else
             BBy = "ASC"
        End If
    Dim PageItems
    Dim nPageCount
    Dim nPage
        nPage = CLng(Request.QueryString("Page"))
    Dim CountPages
    Dim MSiteID
    Dim MSiteName
    Dim MEmailAddress
    Dim MDDate

    'Sets Up Database Connection
    dbName = "/fpdb/topsites.mdb"
    ObjConn= "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath(dbName)

    'Connects to Database
    Set Admin = Server.CreateObject("ADODB.RecordSet")
    If Request.QueryString("Sort") <> "" Then
        If Request.QueryString("Sort") = Approved Then
            If Request.QueryString("By") = Desc Then
                Admin.Open "SELECT * From Users order BY Approved Desc",ObjConn,3,3
            End If
            If Request.QueryString("By") = ASC Then
                Admin.Open "SELECT * FROM Users order BY Approved ASC",ObjConn,3,3
            End If
        End If
        If Request.QueryString("Sort") = SiteID Then
            If Request.QueryString("By") = Desc Then
                Admin.Open "SELECT * FROM Users order BY SiteID Desc",ObjConn,3,3
                MSiteID = "Down"
            End If
            If Request.QueryString("By") = ASC Then
                Admin.Open "SELECT * FROM Users order BY SiteID ASC",ObjConn,3,3
                MSiteID = "Up"
            End If
        End If
        If Request.QueryString("Sort") = SiteName Then
            If Request.QueryString("By") = Desc Then
                Admin.Open "SELECT * FROM Users order BY Site_Name Desc",ObjConn,3,3
                MSiteName = "Down"
            End If
            If Request.QueryString("By") = ASC Then
                Admin.Open "SELECT * FROM Users order BY Site_Name ASC",ObjConn,3,3
                MSiteName = "Up"
            End If
        End If
        If Request.QueryString("Sort") = EmailAddress Then
            If Request.QueryString("By") = Desc Then
                Admin.Open "SELECT * FROM Users order BY Client_Email Desc",ObjConn,3,3
                MEmailAddress = "Down"
            End If
            If Request.QueryString("By") = ASC Then
                Admin.Open "SELECT * FROM Users order BY Client_Email ASC",ObjConn,3,3
                MEmailAddress = "Up"
            End If
        End If
        If Request.QueryString("Sort") = DDate Then
            If Request.QueryString("By") = Desc Then
                Admin.Open "SELECT * FROM Users order BY Date_Created Desc",ObjConn,3,3
                MDDate = "Down"
            End If
            If Request.QueryString("By") = ASC Then
                Admin.Open "SELECT * FROM Users order BY Date_Created ASC",ObjConn,3,3
                MDDate = "Up"
            End If
        End If
    Else
        Admin.Open "SELECT * FROM Users order BY SiteID ASC",ObjConn,3,3
        MSiteID = "Up"
    End If
    PageItems = Admin.PageSize
    nPageCount = Admin.PageCount
    If nPage < 1 Or nPage > nPageCount Then
        nPage = 1
    End If    
%>
</head>
<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="20" height="20" background="http://www.topdeckcards.com/images/headerback.gif"><div align="center"><a href="sites.asp?Sort=Approved&By=<% If BBy = "ASC" Then Response.Write("DESC") Else Response.Write("ASC") %>"><img src="images/alert.gif" width="13" height="13" border="0"></a></div></td>
    <td width="20" height="20" background="http://www.topdeckcards.com/images/headerback.gif"><div align="center"><img src="images/delete.gif" width="14" height="16"></div></td>
    <td width="70" height="20" background="http://www.topdeckcards.com/images/headerback.gif"><div align="left"><strong><a href=sites.asp?Sort=SiteID&By=<%    If BBy = "ASC" Then 
            Response.Write("DESC")
        Else
            Response.Write("ASC") 
        End If
    %>> 
    <% 
    If MSiteID = "Up" Then 
        Response.Write("<img src=images/uparrow.gif width=13 height=13 border=0>") 
    End If 
    If MSiteID = "Down" Then 
        Response.Write("<img src=images/downarrow.gif width=13 height=13 border=0>") 
    End If
    If MSiteID = "" Then 
    Response.Write("")
    End If
    %> Site ID</a></strong></div></td>
    <td width="200" height="20" background="http://www.topdeckcards.com/images/headerback.gif"><div align="left"><strong><a href=sites.asp?Sort=SiteName&By=
    <%    If BBy = "ASC" Then
            Response.Write("DESC") 
        Else 
            Response.Write("ASC") 
        End IF
    %>>
    <%    If MSiteName = "Up" Then
            Response.Write("<img src=images/uparrow.gif width=13 height=13 border=0>")
        End If 
        If MSiteName = "Down" Then 
            Response.Write("<img src=images/downarrow.gif width=13 height=13 border=0>")
        End If 
        If MSiteName = "" Then 
            Response.Write("")
        End If 
    %> Site Name</a></strong></div></td>
    <td width="230" height="20" background="http://www.topdeckcards.com/images/headerback.gif"><div align="left"><strong><a href=sites.asp?Sort=EmailAddress&By=
    <%    If BBy = "ASC" Then 
            Response.Write("DESC") 
        Else 
            Response.Write("ASC") 
        End If
    %>> 
    <%    If MEmailAddress = "Up" Then 
            Response.Write("<img src=images/uparrow.gif width=13 height=13 border=0>") 
        End If 
        If MEmailAddress = "Down" Then 
            Response.Write("<img src=images/downarrow.gif width=13 height=13 border=0>")
        End If 
        If MEmailAddress = "" Then 
            Response.Write("")
        End If 
    %> Email Address</a></strong></div></td>
    <td width="65" height="20" background="http://www.topdeckcards.com/images/headerback.gif"><div align="left"><strong><a href=sites.asp?Sort=DDate&By=
    <%    If BBy = "ASC" Then
            Response.Write("DESC") 
        Else 
            Response.Write("ASC")
        End If
    %>> 
    <%    If MDDate = "Up" Then 
            Response.Write("<img src=images/uparrow.gif width=13 height=13 border=0>")
        End If 
        If MDDate = "Down" Then 
            Response.Write("<img src=images/downarrow.gif width=13 height=13 border=0>")
        End If 
        If MDDate = "" Then
            Response.Write("")
        End If
    %> Date</a></strong></div></td>
  </tr>
<%    Admin.AbsolutePage = nPage
    Do While Not ( Admin.EOF Or Admin.AbsolutePage <> nPage )
%>
  <tr> 
    <td><% If Admin("Approved") <> True Then Response.Write("<div align=center><a href=approve.asp?SiteID="&Admin("SiteID")&"><img src=images/alert.gif width=13 height=13 border=0></a></div>") Else Response.Write("") End IF %></td>
    <td><% Response.Write("<div align=center><a href=delete.asp?SiteID="&Admin("SiteID")&"><img src=images/delete.gif width=13 height=13 border=0></a></div>") %></td>
    <td><% Response.Write("<div align=center><a href=edit.asp?SiteID="&Admin("SiteID")&">"&Admin("SiteID")&"</a></div>") %></td>
    <td><% Response.Write("<div align=left><a href="&Admin("Site_URL")&" target=_blank>"&Admin("Site_Name")&"</a></div>") %></td>
    <td><% Response.Write("<div align=left><a href=Mailto:"&Admin("Client_Email")&">"&Admin("Client_Email")&"</a></div>") %></td>
    <td><% Response.Write("<div align=left>"&Admin("Date_Created")&"</div>") %></td>
  </tr>
<% 
    Admin.MoveNext 
    Loop
%>
</table>
<br>
<div align="center">Page Number:</div>
<div align="center">
<%    For CountPages = 1 to nPageCount 
        Response.Write "<a href=sites.asp?Page="&CountPages& ">" & CountPages & "</a>&nbsp;&nbsp;" 
    Next 
%></div>
</body>
</html>
 
Old July 22nd, 2004, 09:02 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello,

  U missed this statement

set objConn=server.createObject("ADODB.connection")



 
Old July 23rd, 2004, 02:29 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

can u point out where is the line no 89 it will helpfull to find out error

 
Old July 24th, 2004, 01:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, RajaniKrishna is right. You have not created your Connection object, instead setting up all its values and trying to use it. You got to create one before doing so.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting member XSLT 25 July 13th, 2007 08:44 AM
Please Help Me sorting this nj.nikhil BOOK: Beginning ASP 3.0 1 November 10th, 2006 03:45 PM
SORTING pallone XSLT 3 October 29th, 2006 08:45 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
Sorting? pbernardo XSLT 2 October 27th, 2003 11:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.