Forums

This topic is locked

Session Variable, default if NULL?

Posted 28 May 2002 16:19:13
1
has voted
28 May 2002 16:19:13 Mitchel Tendler posted:
Hi,

I have this session variable getting a value:

<% Session("svada_name" = (RS_student.Fields.Item("name_of_ada".Value)%>

It all works fine if a record is found, if a record is not found I get an error because the session variable cannot be set.

Is there a way to set the session variable to whatever value, like 0 if no record is found?

I think it would go something like this but I can't get it to work:

<% if (RS_student.Fields.Item("name_of_ada".Value) <> "" then Session("svada_name" = (RS_student.Fields.Item("name_of_ada".Value)
else Session("svada_name" = "0" %>

Thanks!

Mitch

Replies

Replied 28 May 2002 17:43:55
28 May 2002 17:43:55 Viktor Farcic replied:
<%
If (Not RS_student.EOF) Then
Session("svada_name" = (RS_student.Fields.Item("name_of_ada".Value)
Else
Session("svada_name" = "0"
End If
%>

Viktor Farcic

TalkZone Manager
Replied 28 May 2002 17:59:20
28 May 2002 17:59:20 Mitchel Tendler replied:
PERFECT!!!

Thanks a million!


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
&lt;%
If (Not RS_student.EOF) Then
Session("svada_name" = (RS_student.Fields.Item("name_of_ada".Value)
Else
Session("svada_name" = "0"
End If
%&gt;

Viktor Farcic

TalkZone Manager
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Reply to this topic