Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bluestar
Posting Yak Master
133 Posts |
Posted - 2008-07-28 : 12:34:20
|
helloI am trying to do advance search on my database on multiple tables.The user will enter the search term and select whether they want ALLwords or ANY one words.I am using SQL server 2005.Now I want to use dropdownlist,which will specify from which particular table the search need to be done.Can any one tell me how to add tables in dropdownlist,and how to write sql statement for this.Like select textbox from dropdownlist .And I am doing this in C#.This what I have done so far A stored procedure:CREATE PROCEDURE dbo.sp_AdvanceSearch( @Text VARCHAR(300), @Text1 VARCHAR(300), @Text2 VARCHAR(300))ASSET NOCOUNT ONDECLARE @SQL VARCHAR(8000)SET @Sql = 'SELECT ElementText FROM TextElement WHERE FREETEXT(ElementText, ' + QUOTENAME(@Text, '''') + ' AND ' + QUOTENAME(@Text1, '''') + ' OR ' + QUOTENAME(@Text2, '''') + ')UNION ALL SELECT VideoMimeType FROM VideoElement WHERE FREETEXT(VideoMimeType, , ' + QUOTENAME(@Text, '''') + ' AND ' + QUOTENAME(@Text1, '''') + ' OR ' + QUOTENAME(@Text2, '''') + ')UNION ALLSELECT SESummaryTextFROM SystemElementWHERE FREETEXT(SESummaryText, ' + QUOTENAME(@Text, '''') + ' AND ' + QUOTENAME(@Text1, '''') + ' OR ' + QUOTENAME(@Text2, '''') + ')'EXEC (@SQL)And the C# code :Dictionary<string,object> parameters = new Dictionary<string,object>(); parameters.Add("@Text", TextBox1.Text); parameters.Add("@Text1", TextBox2.Text); parameters.Add("@Text2", TextBox3.Text); dboperations db = new dboperations(); DataSet ds = new DataSet(); ds = db.GetDataset("sp_ASearch", parameters); datagrid1.DataSource = ds; datagrid1.DataBind();please help me to modify my existing code and stored procedure.Thank You |
|
|
|
|
|
|