Posted: 6/27/2011
I declaratively added an SQL datasource. Then a Text Box and a button. When I configured the datasource and my query I added a select all field statement with the following WHERE clause: CONTAINS([ItemName], @ItemName) VALUE SearchTxtBox.TEXT. I did this through the wizard not through code. I then tested the query. I got the following error:
There was an Error Executing the Query
Cannot use a CONTAINS or FREETEXT predicate on a table or indexed view 'DataTable' because it is not full-text indexed.
1. How do I fully text index that table?
2. Or is there a better, or easier way to accomplish what I am trying to do?
What I want is just a simple Text box that an end user can put an item name in and then a detailsview get rendered with the result(s).
Also being that I am new at all this. I could also use some help with the event handler to submit the string from the text box for the query in C#.
Thank you in advance.
Well,
I actually figured this one out. I don't know exactly how. I thought I would post what I did so others could benefit from what I stumbled on. I dragged a SQL datasource, a text box, a button, and a details views onto a page. I configed the datasource. After poiting it to my DB and table, I specified a SELECT query against a form control. That control was my text box. The problem was I kept getting a error that there was no definition for the sqldatasource1_Select event. I guess it automatcally coded this in from the Select statement I specified in the wizard. I went into the source and deleted it. I also changed the select statement from CONTAINS to LIKE. So then I viewed the page in the browser to see if the error went away. It did, the page loaded find. Then just for giggles, I entered a string in the text box and clicked the button. WahLAh.....it submitted the query and the results were displayed in the details view. What I do not under stand is that I did not add an event handler to handle the SearchButton_Click event, but it still submitted the query. I event went to the code behind to make sure, and there is no event handler. How did it know to do this? Am I carzy? I am suprised it worked. Can anyone tell me why?
[quote user="Mike Riemer"]
[/quote]
Hi ,
As you point out your SELECT statement query against some text box placed on your page. This works because of that your SEARCH button rise a post back event. Rising this event trigger the SQLDATASOURCE control which is a server control, and at this moment the SELECT query is getting execute.
I guess this clear enough budy.
About the question how to fully text index a table, reference to this help:
http://technet.microsoft.com/en-us/library/ms187317.aspx
Best Regards,
Gjorgji
Posted: 6/28/2011
Thans for the reference. I get it now.