Querystring prblEM

Results 1 to 5 of 5

Thread: Querystring prblEM

  1. #1
    man of Queries Guest

    Default Querystring prblEM

    yo. <BR><BR>om my page i have a querystring.<BR>with links like:<BR>http://blabla.com/default.asp&number=1<BR><BR>that will not work. i have this code at my default.asp page:<BR>&#039code below<BR><BR>Set Connection = Server.CreateObject("ADODB.Connection")<BR>Connect ion.Open "DBQ=" & Server.Mappath("mydb.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"<BR>SQL = "SELECT * FROM MyTable Order by Id Desc "<BR>Set RS = Connection.Execute(SQL)<BR><BR>select case request.querystring("number")<BR>case 1: SQL = "SELECT * FROM MyTable Order by 1 "<BR>case 2: SQL = "SELECT * FROM MyTable Order by 2 "<BR>case 3: SQL = "SELECT * FROM MyTable Order by 3 "<BR>case 4: SQL = "SELECT * FROM MyTable Order by 4 "<BR>case 5: SQL = "SELECT * FROM MyTable Order by 5 "<BR><BR>End Select<BR>Set RS = Connection.Execute(SQL)<BR><BR>&#039code above<BR><BR>when i press the links with the default.asp&number=1<BR><BR>the page wont even show up!<BR>anyone know the problem? Please answer!<BR>

  2. #2
    Maged Wahba Guest

    Default RE: Querystring prblEM

    Change the "&number=1" to "?number=1" in your link and it&#039ll works correctly..<BR>Good luck

  3. #3
    man of queries?.. Guest

    Default RE: Querystring prblEM

    Yes, no it works! thanks everyone!<BR><BR>But the SQL dont have any effect, it doesnt sort the posts as it should. it is just the same whatever i sort i by.<BR><BR>for example: i have<BR>SQL = "SELECT * FROM MyTable ORDER BY 1"<BR><BR>but nothing changes from the default.asp page...

  4. #4
    Ben Roy Guest

    Default RE: Querystring prblEM

    My first guess is you should try:<BR><BR>default.asp?number=1 instead. <BR><BR>Simple to over look. The "&" is used to separate more than one parameter. For instance:<BR><BR>defalt.asp?number=1&name=jim<BR>< BR>But you need a "?" first instead of the "&"

  5. #5
    Ben Roy Guest

    Default RE: Querystring prblEM

    The order by clause is looking for a field name. For instance if your table had these fields:<BR><BR>FirstName LastName Phone Address<BR><BR>The you could say "ORDER BY LastName" to make it sort on the last field. If you said "ORDER BY johnson" it wouldn&#039t know what you meant. So unless you have fields named "1" "2", etc it shoudn&#039t sort on them.<BR><BR>If what you are wanting to do is FILTER a particular field for only values that match 1, 2, etc then you need to do something different. LIke this:<BR><BR>SELECT * FROM TBLNAME WHERE LastName = "Johnson"<BR><BR>or for your example:<BR><BR>SELECT * FROM MyTable WHERE xxxx(insert fieldname) = 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts