-
Data Mismatch Error
I am creating a search function for a website that will use ASP/VBScript to add a dynamic aspect. One of my search criteria is a dropdown box for price - <1000 or >1000
I am getting a data mismatch error when executing the SQL statement.
Can I use comparison a comparison operator i.e. ">" or "<" to examine a currency data type or must it be numeric only.
Heres the code
Dim price
Dim operator
price = request("price")
if price = "<1000" then
operator = "<"
price = CInt("1000")
elseif price = ">1000" then
operator = ">"
End if
strSQL = "Select * from Rentals Where Price " & operator & " " & price & " AND Bedrooms = ........
Any ideas would be appreciated
-
Re: Data Mismatch Error
You might want to try to Dim your Variable as a valid currency field
Dim price As Currency
Dim Operator As String
this way you'll be sure that everything is the type it's supposed to be.
-
Re: Data Mismatch Error
I tried that with but the same error was occurring
Does anyone know if it is possible to use operators ">" or "<" to examine datatypes other than integers.
I know that it is possible for dates but are currencies compatible?
Mark
-
Re: Data Mismatch Error
I'm not sure but I believe those comparasons will be dependant upon the DB you are using. The solution that comes to my mind would be to add another field to the table and maybe name it pRange. 0 would be less than 1000, 1 would be 1000-2000, etc...Would take a little changing of the code that populates the table but then your calls would all be simple..i.e
strSQL = "Select * from Rentals Where pRange='0' AND Bedrooms = ........