FTS Weighted Values Implementation Problem
- From: Organic Man <davidmcmillin@xxxxxxx>
- Date: Sat, 01 Sep 2007 09:54:34 -0700
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.
.
- Follow-Ups:
- Re: FTS Weighted Values Implementation Problem
- From: Jean-Pierre Riehl
- Re: FTS Weighted Values Implementation Problem
- Next by Date: Re: FTS Weighted Values Implementation Problem
- Next by thread: Re: FTS Weighted Values Implementation Problem
- Index(es):
Relevant Pages
|