| |
|
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.
|
 |

02-04-09, 16:10
|
|
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
|
|

02-04-09, 16:34
|
|
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.
|
|

02-04-09, 16:47
|
|
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
|
|

02-04-09, 17:21
|
|
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.
|
|

02-04-09, 19:41
|
|
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'
|
|

02-05-09, 09:31
|
|
Wage drone 24601
|
|
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
|
|
Is there at least a spoon?
|
|

02-05-09, 10:46
|
|
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 );
}
}
|
|

02-05-09, 10:48
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
dear database.child, did you at least try my query?
|
|

02-05-09, 11:14
|
|
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.
|
|

02-05-09, 11:30
|
|
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.
|
|

02-05-09, 11:48
|
|
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();
}
|
|

02-05-09, 11:56
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
moving thread to ASP forum...
|
|

02-06-09, 03:51
|
|
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?
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|