Results 1 to 4 of 4

Thread: [RESOLVED] [3.0/LINQ] Bindingsource.filter question

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [RESOLVED] [3.0/LINQ] Bindingsource.filter question

    I've done some looking around and im a bit confused


    Here is an example of the data thats in the binding source




    what i want to do is sort on the 3rd row ( 4 or 3) and then sort by the date ( to see if the record is before a certian time


    my idea to do this was to

    filter the BS
    bs.count
    then unfilter the BS


    The problem i keep running into is that i cant say that i want Just 4 or Just 3


    What ive come up with so far is

    c# Code:
    1. private int deadlineCount(DateTime Time, int LeagueID)
    2.         {
    3.             int total = 0;
    4.             string league;
    5.             if (LeagueID == 99)
    6.             {
    7.                 league = "";
    8.             }
    9.             else
    10.             {
    11.                 league = LeagueID.ToString();
    12.             }
    13.  
    14.  
    15.  
    16.             BS.Filter = string.Format("LeagueID >= '{0}' and LeagueID <= '{0}'and [End] <#12/30/1899 {1}#", league, Time.ToString("h:mm tt"));
    17.             total = BS.Count;
    18.             BS.Filter = "";
    19.            
    20.             return total;
    21.        
    22.         }


    But i keep running into problems that i cant use any operator ( like ,> ,= ,>=,) becuase it can not preform X onn system.int32 and system.string.


    I've been looking around but all the example seem to be for strings or dates.

  2. #2

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: [3.0/LINQ] Bindingsource.filter question

    I found this post on the vb.net side

    http://www.vbforums.com/showthread.p...+bindingsource


    which lead me here

    http://msdn.microsoft.com/en-us/libr...xpression.aspx


    thats says i should be able to use

    OPERATORS

    Concatenation is allowed using Boolean AND, OR, and NOT operators. You can use parentheses to group clauses and force precedence. The AND operator has precedence over other operators. For example:

    (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'

    When you create comparison expressions, the following operators are allowed:

    <
    >
    <=
    >=
    <>
    =


    But when i try them i get the same error


    I think im pretty stuck

    any hints?

  3. #3

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: [3.0/LINQ] Bindingsource.filter question

    I was able to bypass this by linking the leagueID feild to the table that assocates it with the acutall leage name ( nba rather than 3 and nfl rather than 4 so on)


    and from there i was able to use a League LIKE 'string' and ........ to get what i need

  4. #4

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: [3.0/LINQ] Bindingsource.filter question

    I figured this out already but is this something i could use LINQ for?

    the filtering of the binding source seems to be a little slow and considering that i only want the count of the filter (all games that start after 7:00 that end before 9 and are NHL = 4 games)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width