Re: FTS Weighted Values Implementation Problem



Hi,

....ISABOUT (' """ & SearchTerm1 & """ ' weight (.8), ...
gives
....ISABOUT (' "a useless phrase " ' weight (.8), ...


The syntax error comes from the simple quotes surrounding your search phrase. The right syntax is :

....ISABOUT ("a useless phrase " weight (.8), ...


--
Jean-Pierre Riehl
http://blog.djeepy1.net
http://www.bewise.fr



"Organic Man" <davidmcmillin@xxxxxxx> wrote in message news:1188665674.075535.103500@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I don't know if this is an appropriate problem for this forum but will
pose it and if anyone can help, I would be very grateful.

I can run this weighted values FTS in Management Studio on a SQL
Server 2005 db:

SELECT FT_TBL.FullDocNo, FT_TBL.DocType, KEY_TBL.RANK
FROM FullDocuments AS FT_TBL INNER JOIN
CONTAINSTABLE(FullDocuments, SectionText,
'ISABOUT (meditation weight (.8),
exercise weight (.4), techniques weight (.2) )' ) AS KEY_TBL
ON FT_TBL.FullDocumentID = KEY_TBL.[KEY]
ORDER BY KEY_TBL.RANK DESC

I can paste that Select statement into my Visual Basic FTS application
and it works fine.

But when I tried to parameterize with search variables for runtime
input from the user via textboxes, I ran into syntax problems. So I
backed up and tried to get just the searchterm to work first (and will
get to the weighted value later):

Dim SearchTerm1 As String
SearchTerm1 = SearchTextBox1.Text.ToString

Dim SearchTerm2 As String
SearchTerm2 = SearchTextBox2.Text.ToString

Dim SearchTerm3 As String
SearchTerm3 = SearchTextBox3.Text.ToString

Dim conn As New SqlConnection("Data Source=xxx")
Dim ds As New DataSet
conn.Open()

'THIS SELECT STATEMENT WORKS
'Dim adp As New SqlDataAdapter("Select FullDocNo, DocType From
FullDocuments WHERE CONTAINS (SectionText, ' """ & SearchTerm1 & """
')", conn)

'THIS SELECT STATEMENT ALSO WORKS
'Dim adp As New SqlDataAdapter("SELECT FT_TBL.FullDocNo,
FT_TBL.DocType, KEY_TBL.RANK FROM FullDocuments AS FT_TBL INNER JOIN
CONTAINSTABLE(FullDocuments, SectionText, 'ISABOUT (meditation weight
(.8), exercise weight (.4), techniques weight (.2) )' ) AS KEY_TBL ON
FT_TBL.FullDocumentID = KEY_TBL.[KEY] ORDER BY KEY_TBL.RANK DESC ",
conn)

'THIS SELECT STATEMENT THROWS A SYNTAX ERROR
Dim adp As New SqlDataAdapter("SELECT FT_TBL.FullDocNo,
FT_TBL.DocType, KEY_TBL.RANK FROM FullDocuments AS FT_TBL INNER JOIN
CONTAINSTABLE(FullDocuments, SectionText, 'ISABOUT (' """ &
SearchTerm1 & """ ' weight (.8), ' """ & SearchTerm2 & """ ' weight (.
4), ' """ & SearchTerm3 & """ ' weight (.2) )' ) AS KEY_TBL ON
FT_TBL.FullDocumentID = KEY_TBL.[KEY] ORDER BY KEY_TBL.RANK DESC ",
conn)

adp.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
conn.Close()

I typed meditation, exercise, and techniques into the three search
textboxes.

The error states: Incorrect syntax near 'meditation'.

Any thoughts on what is wrong with my Select statement?

Thanks in advance for any help provided.


.



Relevant Pages

  • Re: Create table of field names
    ... There seems to be a syntax error on the db.Execute line, ... dates], with field, would I be right in amending the Set td line ... Dim db As DAO.Database ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Need help with Field Codes
    ... All of the braces, including the internal ones, need to be inserted by Word, ... I was able to get past the Syntax Error problem I reported ... I want the field code to be replaced by the current year plus 1. ...
    (microsoft.public.word.newusers)
  • Re: Need help with Field Codes
    ... specifically in the top left hand label. ... I was able to get past the Syntax Error problem I reported ... I want the field code to be replaced by the current year plus 1. ...
    (microsoft.public.word.newusers)
  • Re: Need help with Field Codes
    ... Word MVP FAQ site: http://word.mvps.org ... I was able to get past the Syntax Error problem I reported ... I want the field code to be replaced by the current year plus 1. ...
    (microsoft.public.word.newusers)
  • Re: Syntax checker wtf?
    ... Ruby would give you a syntax error on a multiline ... SyntaxError: compile error ...
    (comp.lang.ruby)