SQL generates 'access violation or syntax' error whencompiled into string var ahead of time

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default SQL generates 'access violation or syntax' error whencompiled into string var ahead of time

    I have stumbled across something perplexing and frustrating, and I'm hoping
    somebody can shed some light here.

    I have a site with some listings. I would like to give the users the ability
    to filter out items from those listings based on certain criteria. They may
    select all, none or some of the filters. As such, I would like to create the
    query programmatically based upon which filters they're applying.

    See the attached code for some insight into what I'm talking about.

    Without any filters supplied, the query should be very simple:

    SELECT * FROM auctions WHERE auctions.end > #createODBCDateTime(now())#

    This should simply return all auctions that have no yet closed, and it DOES as
    long as I put that text as the body of a <CFquery /> but NOT when I put it into
    a variable first, and then use that within' <CFquery />

    What's at play here? Surely ColdFusion is not so unfairly maligned as to now
    allow programmatic construction of queries as I've discussed here!

    mate of the state Guest

  2. Similar Questions and Discussions

    1. Syntax error when trying to update date/time field
      I am getting a MS Access ODBC Syntax error (missing operator) in query expression '2006-01-05 09:17:01.0' when I try to execute an update query. On...
    2. Setting up the date ahead of time
      Hi all, I have a web site that surveys employees to see if they want to work the weekend. One of the problems I'm having is that I don't want to go...
    3. Access Violation error
      Hi Hope you can help. I am trying to run a basic weather script on my homepage .... it is at http://www.phoenixfm.com/phpweather-1.62/test.php...
    4. Planning Your Movie Ahead of Time...(Devil's Advocate anyone?)
      Here's the setup. Awards show. Format is below: Pre-Opening - (a 30 minute or so "screensaver" show that's linear, playing before everyone...
    5. Access Violation Error Using MIAW's
      Hello all, Here's my problem. I am getting an application exception error as shown below when running my application. Below is the message from...
  3. #2

    Default Re: SQL generates 'access violation or syntax' errorwhen compiled into string var ahead of time

    Use:
    <CFquery name="auctions" datasource="#request.dsn#">#PreserveSingleQuotes(a q)#</CFquery>
    OldCFer Guest

  4. #3

    Default Re: SQL generates 'access violation or syntax' errorwhen compiled into string var ahead of time

    Ah! Beautiful! Thanks! :)
    mate of the state Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139