.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 14th, 2004, 01:41 PM
edDev edDev is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 edDev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Double quotes in SQL/.NET trouble

I am stuck trying to pass a search phrase from my .NET app using the CONTAINS() method in SQL.

My SQL Server database has a table with a "contents" column that has full text indexing. In order to search for several words the CONTAINS query must use a combination of single and double quotes:

CONTAINS(contents, '"cats and dogs"')

I want to pass a search phrase variable into this statement from .NET (using a stringBuilder preferably):

sb.Append(" AND CONTAINS(contents, " + searchTerm + ")");

But I cannot see how to pass the quotes and double quotes into SQL.

Is there an easier way of doing this??

Many thanks,

ed

Reply With Quote
  #2  
Old July 8th, 2004, 12:49 PM
StudioReview StudioReview is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 30 StudioReview User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
When your double quotes need to be passed as a string but .NET is interpreting them as double quotes, the first thing you should do is send them as a literal character using the backslash in C#:

C#:
string example = "this is an \"example\" of sending quotes inside a string" ;
sb.Append(" AND CONTAINS(contents, " + example + ")");
__________________
Tivo Codes, Hacking the Tivo, and Adding a Second Drive to Your Tivo.
All this information at www.TivoSpy.com !

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Double quotes in SQL/.NET trouble


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