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, 10:26 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 Request.QueryString problems

Hello, I need some more help! :D I am wanting the user to be able to "resort" the way the recordsets are displayed. So i have a table, and it lists all the recordsets (10 per page), and you can click the columne name and it will resort everything by that columne name. This is parts of my code:

Connection Part:
Code:
<%
    'Declares Variables
    Dim dbName
    Dim ObjConn
    Dim Admin
    Dim PageItems
    Dim nPageCount
    Dim nPage
        nPage = CLng(Request.QueryString("Page"))

    '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")
    Admin.Open "SELECT * FROM Users order BY '" & Request.QueryString("Sort") & "'",ObjConn,3,3
    PageItems = Admin.PageSize
    nPageCount = Admin.PageCount
    If nPage < 1 Or nPage > nPageCount Then
        nPage = 1
    End If    
%>
** So for example if type the address, such as www.server.com/test.asp?Sort=Site_Name

It will not sort it by the site name..... any reason Y?


 
Old July 23rd, 2004, 04:43 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I think the query should be as follows:

 Admin.Open "SELECT * FROM Users order BY " & Request.QueryString("Sort") & "",ObjConn,3,3

But this will give error, if nothing is passed in Request.QueryString("Sort")


Om Prakash
 
Old July 23rd, 2004, 06:48 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes,

  But you can issue that select statement in if condition to avoid errors.

If request.querystring("sort")<>"" then
     admin.open "select * from users order by " & request.querystring("sort"),objconn
end if

 
Old July 23rd, 2004, 10:34 AM
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

That worked! Thanks a lot!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Request.Form / Request.QueryString Toran Classic ASP Databases 4 January 17th, 2007 02:23 PM
Request.Querystring ms_code_bsuter ASP.NET 1.0 and 1.1 Basics 1 February 10th, 2006 08:10 PM
Problem with Request.QueryString mg1966 Classic ASP Databases 4 January 7th, 2005 02:04 PM
request querystring dannyphw ASP.NET 1.0 and 1.1 Basics 1 October 25th, 2004 10:35 AM
request.querystring() , request.form() alyeng2000 ASP.NET 1.0 and 1.1 Basics 1 December 30th, 2003 12:07 AM





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