For Programmers: Free Programming Magazines  


Home > Archive > ASP > October 2006 > Response.Write









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Response.Write
Mangler

2006-10-30, 6:59 pm

Here is an easy one for the pros, yet hard for me (newbie).

If my recordset is empty I want to write "Not Complete" and if there is
a value, I want to write the value. Can someone tell me what I am
doing wrong?

<%
If IsEmpty(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>

Also tried....

<%
If rsa.Fields.Item("reclaima") = "" Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>

Ray Costanzo [MVP]

2006-10-30, 6:59 pm

Try:

If rsa.EOF Then
REsponse.Write "Not complete"
Else
Response.Write rsa.Fields.Item("reclaima").Value
End If

Ray at work

"Mangler" <dwaldman@directwireless.com> wrote in message
news:1161695963.320626.103090@m73g2000cwd.googlegroups.com...
> Here is an easy one for the pros, yet hard for me (newbie).
>
> If my recordset is empty I want to write "Not Complete" and if there is
> a value, I want to write the value. Can someone tell me what I am
> doing wrong?
>
> <%
> If IsEmpty(rsa.Fields.Item("reclaima")) Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>
> Also tried....
>
> <%
> If rsa.Fields.Item("reclaima") = "" Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>



Evertjan.

2006-10-30, 6:59 pm

Mangler wrote on 24 okt 2006 in microsoft.public.inetserver.asp.general:

> Here is an easy one for the pros, yet hard for me (newbie).
>
> If my recordset is empty I want to write "Not Complete" and if there is
> a value, I want to write the value. Can someone tell me what I am
> doing wrong?
>
> <%
> If IsEmpty(rsa.Fields.Item("reclaima")) Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>
> Also tried....
>
> <%
> If rsa.Fields.Item("reclaima") = "" Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>


I surmize the value is null, see below.

This depends on the database settings for that field.

VBS specs say:

IsEmpty returns True if the variable is uninitialized, or is explicitly set
to Empty; otherwise, it returns False. False is always returned if
expression contains more than one variable.

The following example uses the IsEmpty function to determine whether a
variable has been initialized:

Copy Code
Dim MyVar, MyCheck
MyCheck = IsEmpty(MyVar) ' Returns True.
MyVar = Null ' Assign Null.
MyCheck = IsEmpty(MyVar) ' Returns False.
MyVar = Empty ' Assign Empty.
MyCheck = IsEmpty(MyVar) ' Returns True.




--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Ray Costanzo [MVP]

2006-10-30, 6:59 pm

After seeing Evertjan.'s interpretation of your post, I'm thinking you may
mean you're wondering if the data in your recordset is empty, not the
recordset itself. In that case,

Dim s
s = rsa.Fields.Item("reclaima").Value & ""

If s = "" Then
Response.Write "Not Complete"
Else
Response.Write s
End If

''Note that a null value and a value of ""
''will both give you the same output of "Not Complete"

Ray at work

"Mangler" <dwaldman@directwireless.com> wrote in message
news:1161695963.320626.103090@m73g2000cwd.googlegroups.com...
> Here is an easy one for the pros, yet hard for me (newbie).
>
> If my recordset is empty I want to write "Not Complete" and if there is
> a value, I want to write the value. Can someone tell me what I am
> doing wrong?
>
> <%
> If IsEmpty(rsa.Fields.Item("reclaima")) Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>
> Also tried....
>
> <%
> If rsa.Fields.Item("reclaima") = "" Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>



Mangler

2006-10-30, 6:59 pm

Ray,

Tried your code, no luck.

Mangler

2006-10-30, 6:59 pm

> Ray,
>
> Tried your code, no luck.


Scratch that, were good. Thanks guys!

Firas S Assaad

2006-10-30, 6:59 pm

I know everything is working with you now.
but just for the records for the future,
if you encountered this error again, but those ways arent working
anymore, then try looking for the length of the data in the field
example

<%
If len(rsa.Fields.Item("reclaima")) = "0" Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>


Hope this comes in handy sometimes


Best Regards
Firas S Assaad

On Oct 24, 8:55 am, "Mangler" <dwald...@directwireless.com> wrote:[color=darkred]
>

Ray Costanzo [MVP]

2006-10-30, 6:59 pm

I believe this will cause an error if the value is null. Also, Len returns
an integer, not a string, so you'd want to compare it to 0 without the
quotes.

Ray at work

"Firas S Assaad" <firas489@gmail.com> wrote in message
news:1161699465.171242.5290@h48g2000cwc.googlegroups.com...
>I know everything is working with you now.
> but just for the records for the future,
> if you encountered this error again, but those ways arent working
> anymore, then try looking for the length of the data in the field
> example
>
> <%
> If len(rsa.Fields.Item("reclaima")) = "0" Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>
>
> Hope this comes in handy sometimes
>
>
> Best Regards
> Firas S Assaad
>
> On Oct 24, 8:55 am, "Mangler" <dwald...@directwireless.com> wrote:
>



gabba

2006-10-30, 6:59 pm


> If my recordset is empty I want to write "Not Complete" and if there is
> a value, I want to write the value. Can someone tell me what I am
> doing wrong?
>
> <%
> If IsEmpty(rsa.Fields.Item("reclaima")) Then
> Response.Write("Not Complete")
> Else
> Response.Write(rsa.Fields.Item("reclaima"))
> End If
> %>
>


Try this....

If Trim(rsa.Fields.Item("reclaima"))="" or
IsNull(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If

This is right if you consider as "empty": blank text, white spaces, or a
null value.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com