DataSet Select Clarification ???

Rate It (1)

Last post 11-19-2008 7:10 AM by santosh090. 2 replies.

Sort Posts:

  • DataSet Select Clarification ???

    11-18-2008, 7:44 AM
    • Member
      16 point Member
    • santosh090
    • Member since 09-10-2008, 6:21 AM
    • Posts 75

     

    string Name= DDL.SelectedValue.ToString();

    DataRow[] Rows = this.Ds.Tables[0].Select("NAME LIKE '%" + Name+ "%'");

    when I am using above thing it works fine ... but when I am using following

    string TimeStamp= DDL.SelectedValue.ToString();

    DataRow[] Rows = this.Ds.Tables[0].Select("Time_Stamp LIKE '%" + TimeStamp+ "%'");

    it doesnt work (throws error saying that LIKE cannot be used for DATE)... TimeStamp is basically a Date with Time .... so how to get values for DateTime

     

    Thanks In advance

     

    Bye

  • Re: DataSet Select Clarification ???

    11-18-2008, 10:17 AM
    • All-Star
      90,473 point All-Star
    • SGWellens
    • Member since 01-02-2007, 9:27 PM
    • Twin Cities, MN
    • Posts 7,384
    • Moderator
      TrustedFriends-MVPs

    The LIKE clause can only be used with strings.  Time_Stamp is a binary field.

    Depending on what you are trying to do you can use greater than, less than, or, if you are looking for months or days, you may need to pick the date apart into day/month/year components and put them into separate fields to search on.

     

    Steve Wellens

    My blog
  • Re: DataSet Select Clarification ???

    11-19-2008, 7:10 AM
    Answer
    • Member
      16 point Member
    • santosh090
    • Member since 09-10-2008, 6:21 AM
    • Posts 75

     This worked

     DataRow[] Rows = this.Ds.Tables[0].Select("Time_Stamp =' " + TimeStamp+ ' " ");

Page 1 of 1 (3 items)
Microsoft Communities