Results 1 to 4 of 4

Thread: Data Mismatch Error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    17

    Question 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

  2. #2

    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.
    When they say it can't be done, THAT's when they call me ;-)

    MystikShadows
    JC-Hosting.net

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    17

    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

  4. #4
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    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 = ........

Posting Permissions

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



Click Here to Expand Forum to Full Width