469,270 Members | 1,011 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

URGENT: Command Parameter MySQL full text search.

I have an application where I am required to run a full text query. My
database is MySQL and code in C#. The way all queries are SELECT * FROM

table WHERE firstname = ? and using command parameter the value of ? is

added. But, how would I do the same in case of full text search.
SELECT *, ROUND( MATCH(title, comments) AGAINST (? IN BOOLEAN MODE ) *
10, 2 ) AS score FROM table WHERE MATCH(title,comments) AGAINST (? IN
BOOLEAN MODE ) ORDER BY score DESC
When I provide the value as titl*, I don't get anything. But, when I
hard code the query like:
SELECT *, ROUND( MATCH(title, comments) AGAINST ('titl*' IN BOOLEAN
MODE ) * 10, 2 ) AS score FROM table WHERE MATCH(title,comments)
AGAINST ('titl*' IN BOOLEAN MODE ) ORDER BY score DESC
I get good result.
This is how I am building parameters:
public static OdbcCommand BuildCommand ( ArrayList QueryParameters,
string Query )
{
OdbcCommand Command = new OdbcCommand();
Command.CommandType = CommandType.Text;
Command.CommandText = Query;
for( int i = 0; i <= QueryParameters.Count - 1;
i++ )
{
string[] Parameter =
(string[])QueryParameters[ i ];
Command.Parameters.Add( new
OdbcParameter( Parameter[ 0 ],
Parameter[ 1 ] ) );
}
return Command;
}
Any help will be appreciated.
Thanks.

Jan 12 '06 #1
2 2748
Zeya,

Are you sure you are setting the type of the query parameters properly?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Zeya" <ze****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have an application where I am required to run a full text query. My
database is MySQL and code in C#. The way all queries are SELECT * FROM

table WHERE firstname = ? and using command parameter the value of ? is

added. But, how would I do the same in case of full text search.
SELECT *, ROUND( MATCH(title, comments) AGAINST (? IN BOOLEAN MODE ) *
10, 2 ) AS score FROM table WHERE MATCH(title,comments) AGAINST (? IN
BOOLEAN MODE ) ORDER BY score DESC
When I provide the value as titl*, I don't get anything. But, when I
hard code the query like:
SELECT *, ROUND( MATCH(title, comments) AGAINST ('titl*' IN BOOLEAN
MODE ) * 10, 2 ) AS score FROM table WHERE MATCH(title,comments)
AGAINST ('titl*' IN BOOLEAN MODE ) ORDER BY score DESC
I get good result.
This is how I am building parameters:
public static OdbcCommand BuildCommand ( ArrayList QueryParameters,
string Query )
{
OdbcCommand Command = new OdbcCommand();
Command.CommandType = CommandType.Text;
Command.CommandText = Query;
for( int i = 0; i <= QueryParameters.Count - 1;
i++ )
{
string[] Parameter =
(string[])QueryParameters[ i ];
Command.Parameters.Add( new
OdbcParameter( Parameter[ 0 ],
Parameter[ 1 ] ) );
}
return Command;
}
Any help will be appreciated.
Thanks.

Jan 12 '06 #2
Yes. It works for other queries. But fails in this full text search.

Jan 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by karolina | last post: by
6 posts views Thread by lawrence | last post: by
reply views Thread by Henry Hank | last post: by
4 posts views Thread by Michi | last post: by
13 posts views Thread by wideangle | last post: by
67 posts views Thread by Bob Powell | last post: by
4 posts views Thread by Vic Cekvenich | last post: by
5 posts views Thread by annhere | last post: by
7 posts views Thread by Ivan Marsh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.