If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > How to change the row color through query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-09, 16:10
database.child database.child is offline
Registered User
 
Join Date: Nov 2008
Posts: 16
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
Reply With Quote
  #2 (permalink)  
Old 02-04-09, 16:34
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
That's because this is simply not done in the database layer. This is done by the presentation layer.
Reply With Quote
  #3 (permalink)  
Old 02-04-09, 16:47
PMASchmed PMASchmed is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 02-04-09, 17:21
database.child database.child is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 02-04-09, 19:41
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 02-05-09, 09:31
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
Is there at least a spoon?
Reply With Quote
  #7 (permalink)  
Old 02-05-09, 10:46
database.child database.child is offline
Registered User
 
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 );
}
}
Reply With Quote
  #8 (permalink)  
Old 02-05-09, 10:48
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
dear database.child, did you at least try my query?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 02-05-09, 11:14
database.child database.child is offline
Registered User
 
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.
Reply With Quote
  #10 (permalink)  
Old 02-05-09, 11:30
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #11 (permalink)  
Old 02-05-09, 11:48
database.child database.child is offline
Registered User
 
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();
}
Reply With Quote
  #12 (permalink)  
Old 02-05-09, 11:56
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
moving thread to ASP forum...
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #13 (permalink)  
Old 02-06-09, 03:51
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
What is "ListCRVM", is it an ASP control, if so, what kind?
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On