Help with the Find method

Discussion in 'MCSD' started by Kissi, Jan 3, 2004.

  1. Kissi

    Kissi Guest

    Hi,

    Could anyone please help me with the find method. I am trying to search for
    range of dates using the find method. Example: I want to find if
    1/02/2004-1/15/2004 exit in a database. The database has two tables;
    StartDate
    and EndDate.
    Thanks
    Kissi, Jan 3, 2004
    #1
    1. Advertising

  2. >The database has two tables;
    >StartDate
    >and EndDate.


    Do you really mean two columns?
    The Poster Formerly Known as Kline Sphere, Jan 3, 2004
    #2
    1. Advertising

  3. Kissi

    Kissi Guest

    Sorry, the table has two colums.
    StartDate and EndDate.
    "The Poster Formerly Known as Kline Sphere" <.> wrote in message
    news:...
    > >The database has two tables;
    > >StartDate
    > >and EndDate.

    >
    > Do you really mean two columns?
    Kissi, Jan 4, 2004
    #3
  4. >Sorry, the table has two colums.
    >StartDate and EndDate.


    In which case it's best to 'filter' the records within the sql
    statement or stored procedure. Either way the underlying sql would
    look something like this: -

    Select * From YOUR_TABLE Where REQUIRED_DATE Between START_DATE_FIELD
    And END_DATE_FIELD

    If you need to 'filter' out any records after the resultset has been
    processed and returned, you should be able to set the Filter property
    of the recordset, i.e.

    Assuming ADO 2.x here (for ado dot net, you need to look at using a
    dataview).

    YourRecordset.filter = "REQUIRED_DATE > = START_DATE_FIELD and
    REQUIRED_DATE <= END_DATE_FIELD"

    BTW, not sure you should be looking at the Find method
    The Poster Formerly Known as Kline Sphere, Jan 4, 2004
    #4
  5. Kissi

    Jay Walters Guest

    So there are several ways to go about this.

    Find and FindRows are functions of a DataView which
    return an index and array of DataRowView objects
    respectively.

    Personally I use the DataTable.Select method to return an
    array of DataRow objects. Or.. if I'm binding, I create a
    new DataView and use the RowFilter Property to get my sub-
    set.

    Once you start getting in to DataRowView objects it can
    get a little hairy (if you're not very familiar with how
    these objects work in regards to binding).

    If you are looping through the filtered rows just to
    extract data or populate some fields, the array is
    probably lighter and faster ... if you want easy data
    binding you can use the dataview (especially since it has
    additional functions like sorting).

    (To ward off extreme geek comments, you could bind to an
    array of datarows if you really wanted (but it can be a
    pain). Use a "for" loop instead of a "for each" loop for
    maximum performance. Instead of creating a new dataview,
    you can use the DefaultView property of your DataTable,
    but I like to save this as an original copy of my result
    set (it's a consistancy thing for me) and use a new
    DataView for sub-sets.


    >-----Original Message-----
    >>Sorry, the table has two colums.
    >>StartDate and EndDate.

    >
    >In which case it's best to 'filter' the records within

    the sql
    >statement or stored procedure. Either way the underlying

    sql would
    >look something like this: -
    >
    >Select * From YOUR_TABLE Where REQUIRED_DATE Between

    START_DATE_FIELD
    >And END_DATE_FIELD
    >
    >If you need to 'filter' out any records after the

    resultset has been
    >processed and returned, you should be able to set the

    Filter property
    >of the recordset, i.e.
    >
    >Assuming ADO 2.x here (for ado dot net, you need to look

    at using a
    >dataview).
    >
    >YourRecordset.filter = "REQUIRED_DATE > =

    START_DATE_FIELD and
    >REQUIRED_DATE <= END_DATE_FIELD"
    >
    >BTW, not sure you should be looking at the Find method
    >.
    >
    Jay Walters, Jan 5, 2004
    #5
  6. All good stuff Jay. The Select method should achieve the desired
    effect, but the Find method(s) won't help, hence why I commented on
    it.
    On Sun, 4 Jan 2004 20:00:18 -0800, "Jay Walters"
    <> wrote:

    >So there are several ways to go about this.
    >
    >Find and FindRows are functions of a DataView which
    >return an index and array of DataRowView objects
    >respectively.
    >
    >Personally I use the DataTable.Select method to return an
    >array of DataRow objects. Or.. if I'm binding, I create a
    >new DataView and use the RowFilter Property to get my sub-
    >set.
    >
    >Once you start getting in to DataRowView objects it can
    >get a little hairy (if you're not very familiar with how
    >these objects work in regards to binding).
    >
    >If you are looping through the filtered rows just to
    >extract data or populate some fields, the array is
    >probably lighter and faster ... if you want easy data
    >binding you can use the dataview (especially since it has
    >additional functions like sorting).
    >
    >(To ward off extreme geek comments, you could bind to an
    >array of datarows if you really wanted (but it can be a
    >pain). Use a "for" loop instead of a "for each" loop for
    >maximum performance. Instead of creating a new dataview,
    >you can use the DefaultView property of your DataTable,
    >but I like to save this as an original copy of my result
    >set (it's a consistancy thing for me) and use a new
    >DataView for sub-sets.
    >
    >
    >>-----Original Message-----
    >>>Sorry, the table has two colums.
    >>>StartDate and EndDate.

    >>
    >>In which case it's best to 'filter' the records within

    >the sql
    >>statement or stored procedure. Either way the underlying

    >sql would
    >>look something like this: -
    >>
    >>Select * From YOUR_TABLE Where REQUIRED_DATE Between

    >START_DATE_FIELD
    >>And END_DATE_FIELD
    >>
    >>If you need to 'filter' out any records after the

    >resultset has been
    >>processed and returned, you should be able to set the

    >Filter property
    >>of the recordset, i.e.
    >>
    >>Assuming ADO 2.x here (for ado dot net, you need to look

    >at using a
    >>dataview).
    >>
    >>YourRecordset.filter = "REQUIRED_DATE > =

    >START_DATE_FIELD and
    >>REQUIRED_DATE <= END_DATE_FIELD"
    >>
    >>BTW, not sure you should be looking at the Find method
    >>.
    >>
    The Poster Formerly Known as Kline Sphere, Jan 5, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. The Obelisk [7.13.86.42]
    Replies:
    10
    Views:
    1,076
    TechGeekPro
    Jun 4, 2006
  2. picture taker

    edie tapp 90% method of color corection , help please

    picture taker, Nov 29, 2006, in forum: Digital Photography
    Replies:
    0
    Views:
    455
    picture taker
    Nov 29, 2006
  3. mcvishnuprasad

    Help - Method for converting float to double

    mcvishnuprasad, Jan 3, 2008, in forum: The Lounge
    Replies:
    2
    Views:
    8,279
    d_wzrdv_z
    Jul 24, 2008
  4. Kissi

    Help with the Find Method

    Kissi, Jan 3, 2004, in forum: MCAD
    Replies:
    0
    Views:
    461
    Kissi
    Jan 3, 2004
  5. Kissi

    Help with the Find Method

    Kissi, Jan 4, 2004, in forum: MCAD
    Replies:
    0
    Views:
    488
    Kissi
    Jan 4, 2004
Loading...

Share This Page