Sunday, February 19, 2012

"Input string was not in a correct format" when trying to searcg

hi

i have a database with some data in it and iam using full-text-search to search through my data and the search query works fine in sql server manamgnet studio. so my problem is in my web application, i have a textbox where i enter e.g car and click the search button, the button executes the search query but i recive an error"Input string was not in a correct format". here is the code that the button executes:

ProtectedSub searchButton_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

searchSqlDataSource.SelectCommand =

"Select ID, title, FROM myTable WHERE CONTAINS(description, @.search)"

searchSqlDataSource.SelectParameters.Add(

"search", searchTextBox.Text)

searchSqlDataSource.DataBind()EndSub

tnx in advac

can you set the value of a label for instance to the value of the input string so that you can see the actual string? or have you tried stepping through the code and see what the actual string is that is getting sent. if you have access to a sql management studio, you can post the string into the query window and see what is incorrect with the syntax. give those a try and good luck! -- jp|||

I often get that error message when the text contains a semicolon ";". i.e. searchTextBox.text = "johnny went home; vivi left town."

My only resolve was to filter for the semicolon, but I'm sure there's a better way to do it.

Johnny

No comments:

Post a Comment