|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 ! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Double quotes in SQL/.NET trouble |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|