Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Angry Unanswered: ASP parameter passing causing SQL errors

    Hi, if anyone can help or point to a forum message which already has an answer to this I'd be grateful.

    I've got an SQL query, which is built from numeric parameters passed by a form:

    rsSQL = "SELECT COUNT(*) AS count FROM calendar WHERE Year=" & request.form("selYear") & " AND Month=" & request.form("selMonth") & " AND Day=" & request.form("selDay")

    However the following will not open the recordset:

    DB.Open rsSQL, DB_CONNECTIONSTRING, adOpenStatic, adLockPessimistic

    Can anyone advise?! If I change the rsSQL statement to, for example:

    rsSQL = "SELECT COUNT(*) AS count FROM calendar WHERE Year=2003"

    everything works fine. Grr...

    ** Update - fixed. Was passing an empty value which caused the problems. A lesson to be learnt for sure...
    Last edited by mkaka; 09-16-03 at 09:36.

  2. #2
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    try this

    Code:
    Set rsSQL = "SELECT COUNT(*) AS 'count' FROM calendar WHERE Year = " & request.form("selYear") & " AND Month = " & request.form("selMonth") & " AND Day = " & request.form("selDay") & ""

Posting Permissions

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