Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sql query problems

    Hello,

    Once again I am having problems that I think are probably simple formatting mistakes or something, but I need to get this job done before i can take the time to really learn the language, so I'm hoping someone can help me out.

    OK, I think this is all of the relevant code:
    The stuff for opening the connection I think works fine, so I won't paste all of that.


    Dim Query_Sport
    Dim Query_Sex

    Query_Sport = Int(Request.QueryString("sport"))
    Query_Sex = Int(Request.QueryString("sex"))

    sql = "SELECT * FROM [Students] WHERE Sport1 = " & Query_Sport

    sql = sql & " AND Sex = " & Query_Sex


    Now, if I do a response.write, I can see the the querystring is 2, and there are definitely students whose sex = 2, but I get no return.
    And if I query for males (sex=1), I get back only males.
    Confusing

    Let me know if you need to see more code.

    Thanks a lot,
    Brian Hill

  • #2
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Are you executing your sql statement?

    Example:
    Set oRS = oConn.Execute(SQL)

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yup:

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql, conn, 3, 3
    If rs.eof Then
    rs.AddNew
    End If
    Set Session("Students_rs") = rs

    And it works if you query different sports, so I'm guessing the database stuff is working ok.

    -Brian

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What exactly is the problem? If 'the database stuff' is working, why do you then only post the querycomposition?

    You did try a

    response.write SQL

    right? So then just copy paste the generated sql in a querywindow of your db and look if it returns records.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, I don't feel too smart now.

    I was searching for female baseball players, and it seems I hadn't put one in the database.

    Sorry.
    -Brian

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Svenson
    OK, I don't feel too smart now.

    I was searching for female baseball players, and it seems I hadn't put one in the database.

    Sorry.
    -Brian
    Believe me, we've all been there.
    ... female baseball players ... that's enough to make you loose focus
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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