If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP parameter passing causing SQL errors

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-03, 06:40
mkaka mkaka is offline
Registered User
 
Join Date: Sep 2003
Posts: 1
Angry 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 08:36.
Reply With Quote
  #2 (permalink)  
Old 09-20-03, 16:17
Memnoch1207 Memnoch1207 is offline
Registered User
 
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") & ""
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On