how to search the dataset for specific data

I just wanted to ask how to search dataset for specific data because I want to search summary for specific keywords and bind it to repeater I have where expression and it is not working

        string keyword = "where summary like %"+ txtbKeyword.Text +"%" ;


        DataSet ds = new DataSet();
        int selectedTopicID = Convert.ToInt32(ddlTopics.SelectedValue);
        int selectedSkillID = Convert.ToInt32(ddlSkills.SelectedValue);
        int selectedTypeID = Convert.ToInt32(ddlTypes.SelectedValue);
        ds = Resoursce.Search_Resource(selectedTopicID, selectedSkillID, selectedTypeID);
        lbl_totalResult.Text = ds.Tables[0].Rows.Count.ToString();
        rp_resList.DataSource = ds.Tables[0].Select(keyword);
        rp_resList.DataBind();

System.Data.SyntaxErrorException was unhandled by user code

 HResult=-2146232032
  Message=Syntax error: Missing operand after 'summary' operator.
  Source=System.Data
  StackTrace:
       at System.Data.ExpressionParser.Parse()
       at System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
       at System.Data.DataTable.Select(String filterExpression)
       at Christoc.Modules.ResourcesFilter.View.ddlTopics_SelectedIndexChanged(Object sender, EventArgs e) in c:inetpubwwwrootideaParkDesktopModulesResourcesFilterView.ascx.cs:line 120
       at System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
       at System.Web.UI.Page.RaiseChangedEvents()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You could use the DataTable.Select() method.
http://msdn.microsoft.com/en-us/library/t5ce3dyt.aspx

Microsoft’s example:

  // Presuming the DataTable has a column named Date. 
  string expression = "Date = '1/31/1979' or OrderID = 2";
  // string expression = "OrderQuantity = 2 and OrderID = 2";

  // Sort descending by column named CompanyName. 
  string sortOrder = "CompanyName ASC";
  DataRow[] foundRows;

  // Use the Select method to find all rows matching the filter.
  foundRows = table.Select(expression, sortOrder);


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x