URGENT: Command Parameter MySQL full text search.

Z

Zeya

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.
 
N

Nicholas Paldino [.NET/C# MVP]

Zeya,

Are you sure you are setting the type of the query parameters properly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top