Error in performing Fulltext search query.....
Hai,
I am trying to perform FREETEXT search on database. Here is the sample code,
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
sqlDataAdapter1=new SqlDataAdapter ("select * from Student where freetext (*,@srch",sqlConnection1);
sqlDataAdapter1.SelectCommand.Parameters.Add("@srch",SqlDbType.VarChar,20);
sqlDataAdapter1.SelectCommand.Parameters["@srch"].Value=TextBox1.Text;
sqlDataAdapter1.Fill(dataSet1,"Student");
DataGrid1.DataSource=dataSet1;
DataGrid1.DataBind();
}
catch(Exception ex)
{
Label2.Text=ex.ToString();
}
but am stuck with the following error-
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near'@srch'.
Source Error:
Line 98: sqlDataAdapter1.Fill(dataSet1,"Student");//line 98 in red color if Exception not handled
Line 99: DataGrid1.DataSource=dataSet1;
Line 100: DataGrid1.DataBind();
But for SqlDataAdapter constructor, if you pass the string like the one below, it works well,
sqlDataAdapter1=new SqlDataAdapter("select * from Student where freetext(*,"+"\'Jone\'"+")",sqlConnection1);
this works fine, How can I overcome this problem , is any alternative approach.pls help me....

