Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2008
    Posts
    16

    Unanswered: How to change the row color through query

    Hello Experts,

    My requirement is if priority is highest priority then data appears in red color otherwise in black color.


    SELECT * FROM CRVMReq where [Priority] like 'Highest Priority'
    AND ReqStatus like 'OPEN'
    and ReqStatusPool like 'FOCUS'



    if([CRVMReq].[Priority]='Highest Priority')

    {

    ListCRVM.setForeground( Color.red );
    }
    else
    {
    ListCRVM.setForeground( Color.black );

    }

    }


    I don't know how to write it in a query language.
    How i will put query in if loop.

    Please help me.

    Thanks

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    That's because this is simply not done in the database layer. This is done by the presentation layer.

  3. #3
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Application
    Presentation
    Session
    Transport
    Network
    Datalink
    Physical

    I remember this from ye old days of NetWare CNE Exams

  4. #4
    Join Date
    Nov 2008
    Posts
    16
    But the if condition is related to query only.
    If particular field of a table is true then i want query will run.
    So my question is how i will put that condition in if loop.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by database.child
    So my question is how i will put that condition in if loop.
    this is incorrect thinking

    there is no loop


    Code:
    SELECT CRVMReq.* 
         , CASE WHEN Priority =
                  ( SELECT MAX(Priority)
                      FROM CRVMReq 
                     WHERE ReqStatus = 'OPEN'  
                       AND ReqStatusPool = 'FOCUS' )
                THEN 'Highest Priority'
                ELSE 'La-de-dah'
            END as priority
      FROM CRVMReq 
     WHERE ReqStatus = 'OPEN'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Is there at least a spoon?

  7. #7
    Join Date
    Nov 2008
    Posts
    16
    Here I am posting the code which i am executing.


    private Recordset rst = null;
    private Connection dbs = null;
    int NewSqlCount=0;


    {

    rst = dbs.openRecordset( "SELECT * FROM CRVMReq " +
    "where [Priority] like '" +Highest Priority + "%' " +
    "AND ReqStatus like 'OPEN' " +
    "and ReqStatusPool NOT like 'FOCUS' " +
    “and ReadyTD like'YES'”+
    "", AdoConst.adOpenDynamic, 0 );

    if( rst.getRecordCount()>0 )
    {
    NewSqlCount=rst.getRecordCount();

    For(int i=0;i<NewSqlCount ; i++)
    {

    ListCRVM.setForeground( Color.red ); //The problem is at this point.I don't know at this point how i will force to change the color of that rowset only.I hope there must be some propertry of recordset
    }
    }
    Else
    {
    NewSqlCount=0;
    ListCRVM.setForeground( Color.black );
    }

    }

    {

    rst = dbs.openRecordset(select * from CRVMReq where priority!='Highest Priority' and ReqStatus like 'OPEN' and ReqStatusPool not like 'FOCUS'and ReadyTD='YES'+"", AdoConst.adOpenDynamic, 0 );


    if( rst.getRecordCount()>0 )
    {

    NewSqlCount=rst.getRecordCount();

    For(int i=0;i<NewSqlCount ; i++)
    {

    ListCRVM.setForeground( Color.black );
    }

    }
    Else
    {
    NewSqlCount=0;
    ListCRVM.setForeground( Color.black );
    }
    }

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    dear database.child, did you at least try my query?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Nov 2008
    Posts
    16
    I am not facing the problem with query.
    Even my query is picking the right results.
    Problem is for few records i want different color.

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If you don't have a problem with the query, you have a problem with your application code. In which case, you're definately asking in the wrong topic.
    George
    Home | Blog

  11. #11
    Join Date
    Nov 2008
    Posts
    16
    the problem is not with query but with record set property.
    I am looking for the appropriate property.
    I want all the records which rst stores will appears in red color.

    I tried one more concept but even that is not running.
    {

    rst = dbs.openRecordset( "SELECT * FROM CRVMReq " +
    "where [Priority] like 'Highest Priority'" +
    "AND ReqStatus like 'OPEN' " +
    "and ReqStatusPool NOT like 'FOCUS' " +
    "and ReadyTD like'YES'"+
    "", AdoConst.adOpenDynamic, 0 );

    rst.getRecordset();

    {

    ListCRVM.setForeground( Color.red );
    }

    rst.close();

    }
    {

    rst = dbs.openRecordset( "SELECT * FROM CRVMReq " +
    "where [Priority] NOT like 'Highest Priority'" +
    "AND ReqStatus like 'OPEN' " +
    "and ReqStatusPool NOT like 'FOCUS' " +
    "and ReadyTD like'YES'"+
    "", AdoConst.adOpenDynamic, 0 );

    rst.getRecordset();

    {

    ListCRVM.setForeground( Color.black );
    }

    rst.close();
    }

  12. #12
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    moving thread to ASP forum...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  13. #13
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What is "ListCRVM", is it an ASP control, if so, what kind?
    George
    Home | Blog

Posting Permissions

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