Answered by:
Select Case - Represented by Images

Question
-
User-1695179961 posted
I have a question about a Select Case, and how to go about writting it.
In my pages, I call to a SQL Database, that returns values from a column. The columns present two types of data, numeric and varchar
e.g
2N or .10 (they present nickles)
I would like my onscreen to display images, instead of that value (once they have been found).
Where 2N = imageNickle + imageNickle, as well as .10 = imageNickle + imageNickle (or display 2 of the images in place, rather)
I would like to just focus on the (varchar) at this point. Is their an easier way to write a select statement than say:
Select Case howManyImages
If columnValue = 2N then
displayValue = "/imageNickle.jpg" & "/imageNickle.jpg"
ElseIf columnValue = 3N Then
displayValue = "/imageNickle.jpg" & "/imageNickle.jpg & "/imageNickle.jpg"
or is this pretty simple as it is?
Wednesday, September 8, 2010 11:51 AM
Answers
-
User1224194097 posted
I recommend adding those conditions in the sQL query itself
<title>Snippet</title>
Select Case
WHEN columnValue = '2N'
then '/imageNickle.jpg & /imageNickle.jpg'
WHEN columnValue = '3N'
then '/imageNickle.jpg & /imageNickle.jpg & /imageNickle.jpg'
END DisplayValue
FROM MYTABLE
You can retrieve the DisplayValue from CommandObject.ExecuteScalar()
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 8, 2010 1:45 PM -
User-818134166 posted
SELECTCase t1.columnValuewhen '2N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg'when '3N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg' + '&' + '/imageNickle.jpg'EndFROM Table1 t1;SELECT Case t1.columnValue when '2N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg' when '3N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg' + '&' + '/imageNickle.jpg' End FROM Table1 t1;
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 8, 2010 1:57 PM
All replies
-
User1224194097 posted
I recommend adding those conditions in the sQL query itself
<title>Snippet</title>
Select Case
WHEN columnValue = '2N'
then '/imageNickle.jpg & /imageNickle.jpg'
WHEN columnValue = '3N'
then '/imageNickle.jpg & /imageNickle.jpg & /imageNickle.jpg'
END DisplayValue
FROM MYTABLE
You can retrieve the DisplayValue from CommandObject.ExecuteScalar()
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 8, 2010 1:45 PM -
User-818134166 posted
SELECTCase t1.columnValuewhen '2N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg'when '3N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg' + '&' + '/imageNickle.jpg'EndFROM Table1 t1;SELECT Case t1.columnValue when '2N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg' when '3N' Then '/imageNickle.jpg' + '&' + '/imageNickle.jpg' + '&' + '/imageNickle.jpg' End FROM Table1 t1;
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 8, 2010 1:57 PM