Click to See Complete Forum and Search --> : SELECT from DB BETWEEN a range


dizzyfunk
10-24-2003, 03:11 AM
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??

magus
10-24-2003, 03:38 AM
What is the data type of salary_c? if it's numeric your code should be like this:

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


do not use quot mark if it's numeric

dizzyfunk
10-24-2003, 05:18 AM
it's my error!!

the db column name was wrong!!!