FTS Weighted Values Implementation Problem



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: ODBC Connection to SQL Server Compact
    ... Sylvain Lafontaine, ing. ... "The database file has been created by an earlier ... The conn object opened "nicely". ... Dim Conn As ADODB.Connection ...
    (microsoft.public.access.modulesdaovba)
  • Re: updatecommand
    ... Friend Conn As New SqlConnection ... Dim dt As New DataTable ... Private Sub Button1_Click(ByVal sender As System.Object, ... Private Sub executecmd(ByVal cmd As SqlCommand) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Memo field add/update failure
    ... Dim connString ... Set conn = Server.CreateObject ... > with about 700 characters in the Memo field. ...
    (microsoft.public.access.queries)
  • Restrictions accessing MDB (through OLEDB) within .NET applications?
    ... I get the above exception. ... Dim insertCmd As OleDbCommand ... Dim conn As OleDbConnection ...
    (microsoft.public.dotnet.general)
  • Re: excel to sql server (frequently)
    ... "Password=myPassword"Sub UpdateSQLDim conn As ... ADODB.ConnectionDim rst as ADODB.RecordsetDim i as Integerdb = ... So we can buid the connection string correctly. ... Dim connection As String ...
    (microsoft.public.excel.programming)