473,425 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

if statement on cast function possible?

120 100+
I have the following cast function which multiplys a column value by 1.1 to display on a webpage.
Expand|Select|Wrap|Line Numbers
  1. SELECT *, Twin_Band_1 = Cast( Twin_Band_1 * 1.1 as int) FROM MYTABLENAME WHERE ID = '1'"
if twin_band_1 = NULL in sql db isit possible to display '-' instead or a   or any other text for that matter?

thanks in advance
Omar.
Apr 3 '10 #1

✓ answered by omar999

iv figured this out - wohoo. I've used my original sql cast function with corrected asp code as follows;
Expand|Select|Wrap|Line Numbers
  1. ]SELECT *, Twin_Band_1 = Cast( Twin_Band_1 * 1.1 as int) FROM MYTABLENAME WHERE ID = '1'"
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<td>" & replace(objRS(Trim("Twin_Band_1")), "-1", "-") & "</td>"
thanks anyway
omar.

4 2676
Delerna
1,134 Expert 1GB
No both of those are strings and you are casting the field as int

How about something like this

Cast( isnull(Twin_Band_1,-1) * 1.1 as int)


and then on the webpage check for -1.1 and convert it to "&nbsp;" or "-"
Apr 6 '10 #2
omar999
120 100+
thanks delerna - I've tried your suggestion but no joy as the webpage displays "False"
Expand|Select|Wrap|Line Numbers
  1. Twin_Band_1 = Cast( isnull(Twin_Band_1,-1) * 1.1 as int)
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<td>" & objRS("Twin_Band_1") = replace(objRS("Twin_Band_1"), "-1", "testreplace") & "</td>"
not sure where im going wrong?
Apr 6 '10 #3
omar999
120 100+
iv figured this out - wohoo. I've used my original sql cast function with corrected asp code as follows;
Expand|Select|Wrap|Line Numbers
  1. ]SELECT *, Twin_Band_1 = Cast( Twin_Band_1 * 1.1 as int) FROM MYTABLENAME WHERE ID = '1'"
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<td>" & replace(objRS(Trim("Twin_Band_1")), "-1", "-") & "</td>"
thanks anyway
omar.
Apr 6 '10 #4
Delerna
1,134 Expert 1GB
always good to see someone figure out their own problem.
Thanks for the update.
Apr 6 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rachel Weeden | last post by:
I'm working on an ASP Web application, and am having syntax issues in a WHERE statement I'm trying to write that uses the CInt Function on a field. Basically, I want to select records using...
5
by: Luke Dalessandro | last post by:
Code: Thread -> U -> T public class Thread { protected: thread_t _tid; virtual void foo() = 0; public: // Static entry function for the internal thread
10
by: Barbrawl McBribe | last post by:
Is is possible to use typedefs to cast function pointers? I think I saw this in the WINGs src; grep for '(hashFunc)'. So far, trying to use a typedef to cast function pointers so that a return...
24
by: s.subbarayan | last post by:
Dear all, According to standards is this valid: char TmpPtrWriteBuffer; void* PtrWriteBuffer =(void*) TmpPtrWriteBuffer; I had a debate with my colleagues that anything cant be typecasted to...
9
by: Nicolas Blais | last post by:
Hi, I have this following class which I use as a timer: #include <sys/time.h> using namespace std; class chrono { public: chrono() {};
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
4
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a...
18
by: Felix Kater | last post by:
I haven't been thinking about it for years but recently I've stumbled on the fact that 'casting' is actually doing (at least) two different things: On the one hand 'casting' means: 'Change...
6
by: etienne | last post by:
Hello, I am looking for help for a cast problem: I want to run functions in thread, using the pthread_create function. The function to run is the first argument of pthread_create and is expected...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.