?
Solved

SQL Query Help!

Posted on 2003-03-21
2
Medium Priority
?
199 Views
Last Modified: 2013-12-24
I am not sure why, but I am getting an error with the following code:

<cfset test = "FName = 'DAN'">

<cfquery name="GetUsers" datasource="#dsn#">
 SELECT *
 FROM Leads
 WHERE #Test#
</cfquery>

And i get:
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 3: Incorrect syntax near 'DAN'.

0
Comment
Question by:SilverG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 120 total points
ID: 8185001
try using PRESERVESINGLEQUOTES....

<cfset test = "FName = 'DAN'">

<cfquery name="GetUsers" datasource="#dsn#">
SELECT *
FROM Leads
WHERE #preservesinglequotes(Test)#
</cfquery>
0
 

Author Comment

by:SilverG
ID: 8185101
You sir, are the man!

0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
What You Need to Know when Searching for a Webhost Provider
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question