Announcement

Collapse
No announcement yet.

Problem with lookup code

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with lookup code

    I have simple piece of code where I need to select records based on some criteria:

    HTML Code:
    SELECT RegionName, RegionName FROM regions ORDER BY RegionName WHERE Country={Country}
    The {Country} refers to the screen variable on the same form

    This code results however SQL runtime error
    Error while accessing the database:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Country=' at line 1


    (despite I use AJAX). It seems like {Country } is empty (despite is is selected from the dropdown list


    any idea to fix this ?
    Arthur
    -----------------------------------------
    Arthur Klisiewicz
    dATA POINT SOFTWARE
    www.datapointsoftware.com

  • #2
    Originally posted by aka View Post

    any idea to fix this ?
    Yes. :-)


    SELECT RegionName, RegionName FROM regions WHERE Country={Country} ORDER BY RegionName

    The error is almost always before the quoted part of the statement.

    I assume {Country} is integer otherwise is has to be quoted.

    jsb

    Comment


    • #3
      {Country} is a STRING()
      I tried this
      HTML Code:
      SELECT RegionName, RegionName FROM regions ORDER BY RegionName WHERE Country = '{Country}'
      and this
      HTML Code:
      SELECT RegionName, RegionName FROM regions ORDER BY RegionName WHERE Country = {'Country'}
      and nothing seems to work ;-(
      -----------------------------------------
      Arthur Klisiewicz
      dATA POINT SOFTWARE
      www.datapointsoftware.com

      Comment


      • #4
        Try to fill a default value (blank or null) for {Country} in onLoad event.
        Code:
        {Country} = '';

        Comment


        • #5
          SELECT RegionName, RegionName FROM regions WHERE Country={Country} ORDER BY RegionName

          Rearrange the ORDER and WHERE some databases do not allow the ORDER BY before the WHERE

          Comment


          • #6
            Resolved

            rr - THANKS A LOT - your suggestion worked! WOHOO!
            -----------------------------------------
            Arthur Klisiewicz
            dATA POINT SOFTWARE
            www.datapointsoftware.com

            Comment

            Working...
            X