Access Database Value Retrieval

Discussion in 'ASP .Net' started by Sparky Arbuckle, Jun 3, 2005.

  1. I have the following sql statement, typically it would grab a specific
    value but I also want to be able to grab all values within the
    database. Can I use the same SQL statement? I thought I could just use
    * and pull everything but that doesn't appear to work.

    SELECT tblRacers.RacerID, tblRacers.strLName, tblRacers.strFName,
    tblRacers.strAgeCat, tblRacers.strRaceCat FROM tblRacers WHERE
    tblRacers.strAgeCat='" & strAgeCat & "' AND tblRacers.strRaceCat='" &
    strRaceCat & "';

    I thought if the value passed in for strAgeCat/strRaceCat was * it
    would pull all but I guess that isn't the case. Any suggestions on how
    to approach this?

    Thanks!
    Sparky Arbuckle, Jun 3, 2005
    #1
    1. Advertising

  2. Hello

    I don't know what you are stored in strAgeCat but you can form your query
    like this.

    SELECT tblRacers.RacerID, tblRacers.strLName, tblRacers.strFName,
    tblRacers.strAgeCat, tblRacers.strRaceCat FROM tblRacers WHERE
    tblRacers.strAgeCat like '% " & strAgeCat & "%' AND tblRacers.strRaceCat
    like '%" &
    strRaceCat & "'%" ;

    However this is not the proper solution but we can fetch all the records
    from the database not setting the value of strAgeCat/strRaceCat. I mean in
    the absense of the values the query we shall have tblRacers.strAgeCat like
    '%%' and so will get all the records.

    I think it may work for you.

    regards,
    Bhavesh Patel


    "Sparky Arbuckle" wrote:

    > I have the following sql statement, typically it would grab a specific
    > value but I also want to be able to grab all values within the
    > database. Can I use the same SQL statement? I thought I could just use
    > * and pull everything but that doesn't appear to work.
    >
    > SELECT tblRacers.RacerID, tblRacers.strLName, tblRacers.strFName,
    > tblRacers.strAgeCat, tblRacers.strRaceCat FROM tblRacers WHERE
    > tblRacers.strAgeCat='" & strAgeCat & "' AND tblRacers.strRaceCat='" &
    > strRaceCat & "';
    >
    > I thought if the value passed in for strAgeCat/strRaceCat was * it
    > would pull all but I guess that isn't the case. Any suggestions on how
    > to approach this?
    >
    > Thanks!
    >
    >
    =?Utf-8?B?QmhhdmVzaCBQYXRlbA==?=, Jun 3, 2005
    #2
    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. George Sew
    Replies:
    2
    Views:
    482
    bruce barker
    Feb 12, 2004
  2. Rick Spiewak

    Re: HTML Form value retrieval

    Rick Spiewak, May 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    437
    =?Utf-8?B?TWF0dA==?=
    May 7, 2004
  3. tmpm7
    Replies:
    0
    Views:
    373
    tmpm7
    Feb 18, 2008
  4. ArtySin

    textbox retrieval from sql server database

    ArtySin, Dec 2, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    685
    ArtySin
    Dec 2, 2006
  5. Subashini Kumar

    Random record retrieval from database

    Subashini Kumar, Sep 23, 2009, in forum: Ruby
    Replies:
    1
    Views:
    122
    Kaspar Schiess
    Sep 23, 2009
Loading...

Share This Page