By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

My constants are lost?

P: n/a
Greetings!

I have a question about constant.

I have a page like:
----------------------------------------------------------------------
<%
Const adInteger = 3 'copied from adovbs.inc
Const ucApple = 0 'user defined constant
Const ucOrange = 1 'user defined constant
%>

<%
Dim Return_Value
' execute a stored procedure and get the return value
' the return value can only be either 0 or 1
%>
<table>
<tr><td>
<%
If Return_Value = ucApple Then
Response.Write "Apple"
ElseIf Return_Value = ucOrange Then
Response.Write "Orange"
Else
Response.Write "Nothing"
End If
%>
</td></tr>
</table>
-----------------------------------------------------------------------
It prints "Nothing" all the time no matter the stored procedure returns 0 or
1. If I replace "ucApple" with 0 and "ucOrange" with 1, the output is
correct. I believe the user defined constants are lost. But I can use
"adInteger" when I call the stored procedure to create parameters. Why? Am
I doing wrong?

Thanks in advance.

Neo
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Where's Return_Value coming from (post the code). There isn't any reason
that your values would be lost. Your code below should work fine for values
of 0 and 1 (not 3 though...). I'd suggest using a select case structure for
this, but you can worry about that after you figure out why Return_Value
does not have a value.
Select Case CInt(Return_Value)
Case adInteger : Response.Write "AdInteger value was returned."
Case ucApple : Response.Write "An apple value was returned."
Case ucOrange : Response.Write "An orange value was returned."
Case Else : Response.Write "No worthwhile value was returned."
End Select

Ray at home
--
Will trade ASP help for SQL Server help
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Greetings!

I have a question about constant.

I have a page like:
----------------------------------------------------------------------
<%
Const adInteger = 3 'copied from adovbs.inc
Const ucApple = 0 'user defined constant
Const ucOrange = 1 'user defined constant
%>

<%
Dim Return_Value
' execute a stored procedure and get the return value
' the return value can only be either 0 or 1
%>
<table>
<tr><td>
<%
If Return_Value = ucApple Then
Response.Write "Apple"
ElseIf Return_Value = ucOrange Then
Response.Write "Orange"
Else
Response.Write "Nothing"
End If
%>
</td></tr>
</table>
-----------------------------------------------------------------------
It prints "Nothing" all the time no matter the stored procedure returns 0 or 1. If I replace "ucApple" with 0 and "ucOrange" with 1, the output is
correct. I believe the user defined constants are lost. But I can use
"adInteger" when I call the stored procedure to create parameters. Why? Am I doing wrong?

Thanks in advance.

Neo

Jul 19 '05 #2

P: n/a
Thanks for your reply.

In fact, Not the return value is lost, but the constants I assign.

In my case below, ucApple is no longer equal to "0" and ucOrange is no
longer "1" after executing stored procedure. The return value is actually
"0", but 0 (Return_Value) is not equal to "Null" (ucApple), so it doesn't
work. But if I try

Select Case CInt(Return_Value)
Case 0 : Response.Write "An apple value was returned."
Case 1 : Response.Write "An orange value was returned."
Case Else : Response.Write "No worthwhile value was returned."
End Select

It works. I'm confusing...

Neo
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
Where's Return_Value coming from (post the code). There isn't any reason
that your values would be lost. Your code below should work fine for values of 0 and 1 (not 3 though...). I'd suggest using a select case structure for this, but you can worry about that after you figure out why Return_Value
does not have a value.
Select Case CInt(Return_Value)
Case adInteger : Response.Write "AdInteger value was returned."
Case ucApple : Response.Write "An apple value was returned."
Case ucOrange : Response.Write "An orange value was returned."
Case Else : Response.Write "No worthwhile value was returned."
End Select

Ray at home
--
Will trade ASP help for SQL Server help
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Greetings!

I have a question about constant.

I have a page like:
----------------------------------------------------------------------
<%
Const adInteger = 3 'copied from adovbs.inc
Const ucApple = 0 'user defined constant
Const ucOrange = 1 'user defined constant
%>

<%
Dim Return_Value
' execute a stored procedure and get the return value
' the return value can only be either 0 or 1
%>
<table>
<tr><td>
<%
If Return_Value = ucApple Then
Response.Write "Apple"
ElseIf Return_Value = ucOrange Then
Response.Write "Orange"
Else
Response.Write "Nothing"
End If
%>
</td></tr>
</table>
-----------------------------------------------------------------------
It prints "Nothing" all the time no matter the stored procedure returns
0 or
1. If I replace "ucApple" with 0 and "ucOrange" with 1, the output is
correct. I believe the user defined constants are lost. But I can use
"adInteger" when I call the stored procedure to create parameters. Why?

Am
I doing wrong?

Thanks in advance.

Neo


Jul 19 '05 #3

P: n/a
Your constants will not lose their values, unless you have them in another
page or something...

Post your code.

Ray at home

--
Will trade ASP help for SQL Server help
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thanks for your reply.

In fact, Not the return value is lost, but the constants I assign.

In my case below, ucApple is no longer equal to "0" and ucOrange is no
longer "1" after executing stored procedure. The return value is actually
"0", but 0 (Return_Value) is not equal to "Null" (ucApple), so it doesn't
work. But if I try

Select Case CInt(Return_Value)
Case 0 : Response.Write "An apple value was returned."
Case 1 : Response.Write "An orange value was returned."
Case Else : Response.Write "No worthwhile value was returned."
End Select

It works. I'm confusing...

Neo

Jul 19 '05 #4

P: n/a

If CLng(Return_Value) = CLng(ucApple) Then

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearning.com
http://www.ielearning.com
714.637.9480 x17
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Greetings!

I have a question about constant.

I have a page like:
----------------------------------------------------------------------
<%
Const adInteger = 3 'copied from adovbs.inc
Const ucApple = 0 'user defined constant
Const ucOrange = 1 'user defined constant
%>

<%
Dim Return_Value
' execute a stored procedure and get the return value
' the return value can only be either 0 or 1
%>
<table>
<tr><td>
<%
If Return_Value = ucApple Then
Response.Write "Apple"
ElseIf Return_Value = ucOrange Then
Response.Write "Orange"
Else
Response.Write "Nothing"
End If
%>
</td></tr>
</table>
-----------------------------------------------------------------------
It prints "Nothing" all the time no matter the stored procedure returns 0 or 1. If I replace "ucApple" with 0 and "ucOrange" with 1, the output is
correct. I believe the user defined constants are lost. But I can use
"adInteger" when I call the stored procedure to create parameters. Why? Am I doing wrong?

Thanks in advance.

Neo

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.