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 July 15th, 2004, 10:53 AM
BGrphc BGrphc is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 BGrphc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL searching problem

Please help?
I'm having a problem with a SQL search query when using LIKE.
When I call the query through an ASP page, No results are found. If I copy and paste that exact same SQL statement into EM, or Query Analyzer I get the record I need. The SQL statement is pasted below, ANY help would be greatly appreciated.
Thank You
BGrphc

SELECT * FROM ARCHIVED_LISTINGS WHERE ( Status='A' OR Status='PC' OR Status='PS' OR Status='X' OR Status='T' OR Status='CS' OR Status='W' OR Status='NA' ) AND (MLS# LIKE '%searchString%' OR OwnerName LIKE '%searchString%' OR C_S_Address LIKE '%searchString%' OR Property LIKE '%searchString%' OR CONVERT(varchar, Price) Like '%searchString%' OR Associate LIKE '%searchString%' OR Condo_Sub LIKE '%searchString%' OR Other_MLS# LIKE '%searchString%' ) ORDER BY [OwnerName];

Reply With Quote
  #2  
Old July 15th, 2004, 10:58 AM
Kris_Vanherck's Avatar
Kris_Vanherck Kris_Vanherck is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Belgium, Antwerp
Posts: 177 Kris_Vanherck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 sec
Reputation Power: 5
if it works in query analyzer then the problem should lie in how ASP sends it or how it fills '%searchString%

Reply With Quote
  #3  
Old July 15th, 2004, 11:08 AM
BGrphc BGrphc is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 BGrphc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Kris,
This seems to happening with only a handfull of records. So since it works part of the time, I would think that ASP is sending correctly (I could be wrong though.)

Reply With Quote
  #4  
Old July 15th, 2004, 11:29 AM
stevemw stevemw is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: uk
Posts: 70 stevemw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
try a response.write straight after you code that builds the SQL. It will print the results on screen then for you to see what happens. For instance if your sql statement is declared as sqldec

response.write sqldec
response.end

Reply With Quote
  #5  
Old July 15th, 2004, 11:40 AM
BGrphc BGrphc is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 BGrphc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you everyone for your replies, problem Solved.
Stupid error on my part that has had me going since yesterday morning.

The error was that there are 2 sql statements on that page for 2 separate DBs, the statement I posted earlier was tucked neatly inside of an
IF Not SQL1.EOF THEN
so I was only getting results from SQL2 if SQL1 was not empty.

Thanks again everyone.
BGrphc

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL searching problem


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 6 hosted by Hostway
Stay green...Green IT