473,799 Members | 3,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Full-Text Search in VB code

I'm trying to execute a full-text query from a vb.net web application.

The problem I have is that in SQL Server, the syntax for a full-text
search is

SELECT *
FROM table
WHERE CONTAINS( *, ' "searchstri ng" ')

For whatever reason, VB won't run that search string unless I eliminate
the double sets of quotes:

SELECT *
FROM table
WHERE CONTAINS( *, "searchstri ng")

This will not work for a search phrase - only single words, and it also
will not work for a wild card:

SELECT *
FROM table
WHERE CONTAINS ( *, "search*")

The above does not work - I must assume that the double quotes are
needed for both wild card searches and exact phrase searches -

The problem of course is that in vb code the SQL string is already
enclosed in search quotes - the single quotes are then used to indicate
double quotes within the search.

I have tried using two single quotes on either side of the string, but
it doesn't seem to work. ie:

"SELECT * FROM table WHERE CONTAINS ( ' '" & textbox1.text & "' ')"

Does anybody have any ideas?

Trevor Fairchild

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
3 15334
A: the SQL wildcard is % not * as in Access

B: SQL uses single quotes ' not double "

On 20 Nov 2003 18:50:36 GMT, Trevor Fairchild <ba*********@ao l.com>
wrote:
I'm trying to execute a full-text query from a vb.net web application.

The problem I have is that in SQL Server, the syntax for a full-text
search is

SELECT *
FROM table
WHERE CONTAINS( *, ' "searchstri ng" ')

For whatever reason, VB won't run that search string unless I eliminate
the double sets of quotes:

SELECT *
FROM table
WHERE CONTAINS( *, "searchstri ng")

This will not work for a search phrase - only single words, and it also
will not work for a wild card:

SELECT *
FROM table
WHERE CONTAINS ( *, "search*")

The above does not work - I must assume that the double quotes are
needed for both wild card searches and exact phrase searches -

The problem of course is that in vb code the SQL string is already
enclosed in search quotes - the single quotes are then used to indicate
double quotes within the search.

I have tried using two single quotes on either side of the string, but
it doesn't seem to work. ie:

"SELECT * FROM table WHERE CONTAINS ( ' '" & textbox1.text & "' ')"

Does anybody have any ideas?

Trevor Fairchild

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 20 '05 #2

"Trevor Fairchild" <ba*********@ao l.com> wrote in message
news:3f******** *************@n ews.frii.net...
I'm trying to execute a full-text query from a vb.net web application.

The problem I have is that in SQL Server, the syntax for a full-text
search is

SELECT *
FROM table
WHERE CONTAINS( *, ' "searchstri ng" ')

For whatever reason, VB won't run that search string unless I eliminate
the double sets of quotes:

SELECT *
FROM table
WHERE CONTAINS( *, "searchstri ng")

This will not work for a search phrase - only single words, and it also
will not work for a wild card:

SELECT *
FROM table
WHERE CONTAINS ( *, "search*")

The above does not work - I must assume that the double quotes are
needed for both wild card searches and exact phrase searches -

The problem of course is that in vb code the SQL string is already
enclosed in search quotes - the single quotes are then used to indicate
double quotes within the search.

I have tried using two single quotes on either side of the string, but
it doesn't seem to work. ie:

"SELECT * FROM table WHERE CONTAINS ( ' '" & textbox1.text & "' ')"

Does anybody have any ideas?

Trevor Fairchild

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


I would guess that you have an issue with escaping the different type of
quotes in VB. If you build the complete command in VB then print it, does it
have the correct SQL Server syntax? It's not completely clear from your post
if you've tried this. You may need one of the following (untested):

/* Simple phrase */
"SELECT * FROM table WHERE CONTAINS ( *, ' """ & textbox1.text & """ ')"
/* Single word */
"SELECT * FROM table WHERE CONTAINS ( *, '" & textbox1.text & "')"

Simon
Jul 20 '05 #3
I found the answer elsewhere.

Thank you, though.

I had to use Chr(34), which is the ASCII code for a double quote, to
force an insert of double quotes into the SQL string on either side of
the search criteria.

It should be noted that I could only get the * working as a wildcard - %
did not work in VB.NET.

The Full-Text syntax specifically stated that the search criteria was
double-quoted, and then the search string Plus the double-quotes were
then surrounded by single quotes (I do not know why):

This is what I had to do to get it working:

command.Command Text = "SELECT * FROM table WHERE CONTAINS ( ' " &
chr(34) & "mySearchHe re" & chr(34) & " ' )"

This comes out looking like:

SELECT * FROM table WHERE CONTAINS( ' "mySearchHe re" ')

And that is how the help in SQL Server 2000 showed it...

Thanks, everyone!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3828
by: daking | last post by:
I'm trying to track down a Java performance issue, and believe it may be related to GC behavior. Quick background: j2se app server running Caucho Resin 2.1.12, on RHEL3 with Sun JDK 1.4.2_04, modest number of threads, serving approx 50-150 requests per second. The system runs as expected until the first Full GC, which happens as normal, when the heap has reached near full. .... 9235.733:
7
6237
by: alexcn | last post by:
I have the following query: SELECT dbo.tSymExch.exCode, dbo.tSymGrp.sgCode, dbo.tSymMain.smCode FROM dbo.tSymExch FULL OUTER JOIN dbo.tSymGrp ON dbo.tSymExch.exID = dbo.tSymGrp.sgexID FULL OUTER JOIN dbo.tSymMain ON dbo.tSymGrp.sgID = dbo.tSymMain.smsgID Which produces:
1
3202
by: onewebclick | last post by:
Is there a way to detect a browser cache is full using javascript or HTML thorugh a web page and inform the user to clear the cache to improve performance of the website. It looks like google's gmail use to detect and warn "Gmail says my browser's cache is full" http://gmail.google.com/support/bin/answer.py?answer=14106 then there should be a way to do it if google can do it. Any thoughts ?
1
3485
by: Jimmy Chen | last post by:
Recently I've done a db2 backup and restore/recovery, but the process for recovering the database was different than what I thought to be. here is what I did: DB2 is set in online mode - backup - * backup db2 in full * insert record
2
5089
by: Lee | last post by:
I have two identical schema tables (one in a production library and another in a development library) and I need to be able to easily compare the data in them for errors and omissions. With another relational database (can you guess which?) I was able to do the following: SELECT * FROM tableA A FULL OUTER JOIN tableB B ON A.KEY=B.KEY WHERE A.KEY IS NULL OR B.KEY IS NULL OR A.DATA<>B.DATA I am trying to do the same thing on DB2 v5r3...
9
2746
by: Aleksey Serba | last post by:
Hello! I have 24/7 production server under high load. I need to perform vacuum full on several tables to recover disk space / memory usage frequently ( the server must be online during vacuum time ) The one trick that i see is to try to vacuum duplicate of production database ( or just some tables ). But there are some pitfalls: http://www.postgresql.org/docs/7.4/interactive/backup-file.html
11
8298
by: rh00667 | last post by:
hi all, i'm confused now. how i can get the full path of an application? if myapp is in a directory which belongs to PATH, argv gives me the first token of cmd line, and not the real path of the executed program. so if i write anywhere:
4
18236
by: Brian D | last post by:
In MS SQL 2005 when you do a Full Backup does it also backup and truncate the transaction logs or do I need to back the transaction logs up separately? Thanks. Brian
1
2607
by: vivek samantray | last post by:
I have a query.When i try to create a index on one of the table the index gets created but when i take the output it stuill shows "TABLE ACCESS FULL" Please see below what i did QUERY ====== SELECT b.DPT_EVNT_ID, b.DPT_ENTITY_ID, a.EDD_DT, b.DPT_DPT_ID, b.OU_ID,
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.