Forums

ASP

This topic is locked

SELECT from DB BETWEEN a range

Posted 24 Oct 2003 10:59:29
1
has voted
24 Oct 2003 10:59:29 Sean Johnson posted:
i want to search my DB for people with a salary between a range.

i'm using asp/vbscript & msaccess
i'm building a dynamic SQL string and here's the code for that bit:

if len(strSalarylo) > 0 then
strSQL = strSQL & " AND salary_c >= '" & strSalarylo & "' AND salary_c <= '" & strSalaryhi & "'"
end if

this tags on to:

rsIRS.Source = "SELECT * FROM resource_t WHERE validated_c = TRUE" & strSQL & ""

However i get this error:

[ODBC Microsoft Access Driver] Too few parameters. Expected 1

i have also tried this:

if len(strSalarylo) > 0 then
strSQL = strSQL & " AND salary_c BETWEEN '" & strSalarylo & "' AND '" & strSalaryhi & "'"
end if

same error occurs??<font face='Arial'></font id='Arial'>

Replies

Replied 27 Oct 2003 02:10:47
27 Oct 2003 02:10:47 Phil Shevlin replied:
I don't use msaccess, but do you need single quotes around the integers? That might be causing some problem...

if len(strSalarylo) &gt; 0 then
strSQL = strSQL & " AND salary_c BETWEEN " & strSalarylo & " AND '" & strSalaryhi""
end if
Replied 27 Oct 2003 10:00:48
27 Oct 2003 10:00:48 Sean Johnson replied:
i was told that the error:
[ODBC Microsoft Access Driver] Too few parameters. Expected 1

sometimes means that the db columns are wrong - i checked it and this was the problem....

i have a db column called current_salary_c NOT just salary_c

hope this helps anyone else in future!

Reply to this topic