Filter records in DataSet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raymond Chiu

    #1

    Filter records in DataSet

    Dear all,

    If I have the dataset, What the code should be to filter records in the
    dataset by some fields criteria? Is it like a SQL?

    Thanks for your help,


  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: Filter records in DataSet

    Raymond Chiu wrote:
    Dear all,
    >
    If I have the dataset, What the code should be to filter records in the
    dataset by some fields criteria? Is it like a SQL?
    >
    Thanks for your help,
    >
    You can use a DataView to filter a DataTable.

    The DefaultView property in the DataTable returns the default DataView
    of the table, which by default has an empty filter, i.e. returning all
    rows of the DataTable.

    Setting the RowFilter property changes the filter. Example:

    someDataTable.D efaultView.RowF ilter = "City = 'Västerås'"

    If you want more than one filter on the same table (or don't want to
    change the default filter), you can create new DataView objects.

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    • sloan

      #3
      Re: Filter records in DataSet


      There is a .Select method.


      MyDS.MyTable.Se lect("EmpID=123 ");
      MyDS.MyTable.Se lect("LastName= 'John'");

      It is NOT as powerful as tsql/sql select. But gives you some basic
      functionality.


      "Raymond Chiu" <rchiu5hk@yahoo .com.hkwrote in message
      news:OW59Ryh8IH A.1080@TK2MSFTN GP06.phx.gbl...
      Dear all,
      >
      If I have the dataset, What the code should be to filter records in the
      dataset by some fields criteria? Is it like a SQL?
      >
      Thanks for your help,
      >

      Comment

      Working...