Re: FTS Weighted Values Implementation Problem
- From: "Jean-Pierre Riehl" <jean-pierre.riehl@xxxxxxxxxxxxxx>
- Date: Mon, 3 Sep 2007 19:12:27 +0200
It is another VB.NET syntax problem ;-)
You have to convert your numeric value to string with ToString() function. Double quote are useless as you expect that result : weight(0.8)
New query is :
[...] 'ISABOUT (""" + SearchTerm1 + """ weight ( + RealWeight1.ToString() + ), """ + SearchTerm2 [...]
--
Jean-Pierre Riehl
http://blog.djeepy1.net
http://www.bewise.fr
"Organic Man" <davidmcmillin@xxxxxxx> wrote in message news:1188837558.402664.317710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FANTASTIC!!! Sorry for the confusion in how I originally presented my
situation.
Now for the second part of my problem wherein I allow the user to type
a number into a textbox which assigns the weight value for each
SearchTerm.
I don't want the user to have to work with decimals directly, so I
will have a label with the instruction to type a number between 1-9
into each WeightTextBox corresponding to each SearchTerm. Then I will
convert it to decimal in code. For SearchTerm1 I have created
WeightTextBox1 and written this code:
Dim Weight1 As Integer
Weight1 = WeightTextBox1.Text
Dim RealWeight1 As Decimal
RealWeight1 = Weight1 * 0.1
I adjusted my SELECT statement using the syntax you provided for the
SearchTerm variable which is applied to the RealWeight1 variable:
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 (""" + RealWeight1 + """), """ + SearchTerm2 + """ weight
(.4), """ + SearchTerm3 + """ weight (.2) )' ) AS KEY_TBL ON
FT_TBL.FullDocumentID = KEY_TBL.[KEY] ORDER BY KEY_TBL.RANK DESC ",
conn)
I step through the code in Debugger mode and the value of RealWeight1
= 0.8D
But I get this error when it comes to the SELECT statement:
System.InvalidCastException was unhandled
Message="Conversion from string "SELECT FT_TBL.FullDocNo, FT_TBL." to
type 'Double' is not valid."
I was not sure if there was something wrong with my code syntax or if
it was a datatype problem (should have used double instead of
decimal). So I created a version with double datatype instead of
decimal. The error message was the same.
I figured that the syntax using multiple quotes was suitable for
string datatype (but not decimal or double), so I eliminated them and
tried various ways of presenting RealWeight1, but always get syntax
errors. FYI: When switching to double datatype the value was 0.8
instead of 0.8D that resulted from decimal datatype (although I doubt
that is the root of the problem).
Thanks for your help so far and any further advice you can provide in
helping me to get this functional.
On Sep 3, 11:16 am, "Jean-Pierre Riehl" <jean-pierre.ri...@xxxxxxxxxxxxxx> wrote:
Ok, I understand.
Your syntax error is a VB.NET compilation error under Visual Studio. We
misunderstood each other.
With VB.NET :
Dim tsql as String = String.Format("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
'string above is on a unique line of code
Dim adp as SqlDataAdapter = new SqlDataAdapter(tsql, conn)
With T-SQL, full-text pattern is a string (nvarchar). In your last query, it
consider @Term as literal value. You also have to concatenate query :
[...] 'ISABOUT ("' + @SearchTerm1 + '" weight (.8), "' + @SearchTerm2 + '"
weight (.4),[...]
--
Jean-Pierre Riehlhttp://blog.djeepy1.nethttp://www.bewise.fr
"Organic Man" <davidmcmil...@xxxxxxx> wrote in message
news:1188831562.850977.193840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: FTS Weighted Values Implementation Problem
- From: Organic Man
- Re: FTS Weighted Values Implementation Problem
- References:
- FTS Weighted Values Implementation Problem
- From: Organic Man
- Re: FTS Weighted Values Implementation Problem
- From: Jean-Pierre Riehl
- Re: FTS Weighted Values Implementation Problem
- From: Organic Man
- Re: FTS Weighted Values Implementation Problem
- From: Jean-Pierre Riehl
- Re: FTS Weighted Values Implementation Problem
- From: Organic Man
- Re: FTS Weighted Values Implementation Problem
- From: Jean-Pierre Riehl
- Re: FTS Weighted Values Implementation Problem
- From: Organic Man
- Re: FTS Weighted Values Implementation Problem
- From: Jean-Pierre Riehl
- Re: FTS Weighted Values Implementation Problem
- From: Organic Man
- FTS Weighted Values Implementation Problem
- Prev by Date: Re: FTS Weighted Values Implementation Problem
- Next by Date: Re: FTS Weighted Values Implementation Problem
- Previous by thread: Re: FTS Weighted Values Implementation Problem
- Next by thread: Re: FTS Weighted Values Implementation Problem
- Index(es):
Relevant Pages
|