Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 10th, 2005, 09:46 AM
internetliquid internetliquid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: UK and Orange County CA
Posts: 3 internetliquid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to internetliquid
Problem parsing dynamic WHERE clause to SPROC

I have a dynamic sql WHERE clause that is built in ASP and sent to a sproc in SQL Server. The string works fine when parsed directly to the sproc in SQL Query Analyser, but when sent to the sproc from an ASP script the sproc fails dues to the quote marks used in the WHERE clause string.

strWhereClause
(map_x >= 642343 AND map_y >= 281276) AND (map_x <= 668108 AND map_y <= 307041) AND (pt.property_typeID = ''HDE'' OR pt.property_typeID = ''HSD'' OR pt.property_typeID = ''HTE'') AND (bedrooms BETWEEN 0 AND 8) AND (bathrooms BETWEEN 0 AND 8) AND (sale_statusID = ''FSL'' OR sale_statusID = ''UOF'' OR sale_statusID = ''SLD'') AND (property_termID = ''FRE'' OR property_termID = ''FSH'' OR property_termID = ''LEA'') AND p.listing_typeID = ''S''



Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'HDE'. /tradingplaces/search.asp, line 183



As you can see the where clause contains double single quotes around each variable, is there another type of quote or is there a way around this? For example is there a SQL server equivalent to \' like in javaScript? When run in query analyser with the same WHERE clause it works fine...
DECLARE @return int, @row_total int

EXEC @return = LM001_search
@where_clause = '(map_x >= 642343 AND map_y >= 281276) AND (map_x <= 668108 AND map_y <= 307041) AND (pt.property_typeID = ''HDE'' OR pt.property_typeID = ''HSD'' OR pt.property_typeID = ''HTE'') AND (bedrooms BETWEEN 0 AND 8) AND (bathrooms BETWEEN 0 AND 8) AND (sale_statusID = ''FSL'' OR sale_statusID = ''UOF'' OR sale_statusID = ''SLD'') AND (property_termID = ''FRE'' OR property_termID = ''FSH'' OR property_termID = ''LEA'') AND p.listing_typeID = ''S''',
@page_num = 1,
@page_size = 10,
@total_rows = @row_total output

SELECT @return, @row_total
Any ideas???

Thanks,
Julian.

Reply With Quote
  #2  
Old May 10th, 2005, 11:55 AM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,867 mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 4 Weeks 15 h 20 m 54 sec
Reputation Power: 1762
Try replacing your double quotes with a single quote.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Problem parsing dynamic WHERE clause to SPROC


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT