Can someone please shed some light as to why this will not work
properly:

<%
If (News.Fields.Item("Chart").Value) = "" Then
Response.Write "Not Available"
Else
Response.Write "<img src='" &
News.Fields.Item("Chart").Value & "'>"
End If
%>

The check works fine...even the first response.write works... but the
second response.write never inserts the database field information. I
have 3 sets of data in the database, the first and last have data in
the "Chart" field (data in field = test), the second is empty. Here is
what I get:

<img src=''>
Not Available
<img src=''>

Re: Response.Write Text with DataField by Firas

Firas
Wed Apr 12 11:08:52 CDT 2006

Hi,

This problem used to accure with me, until i started retriving data from
the database in an other way;
instead of
News.Fields.Item("Chart").Value
use
News.Fields("Chart")

if it didnt work, remove any "On Error resume next" from ur code
and if didnt work, open the Query in the database and check if it does
show any records, if not that means that u have an error in ur Query
Statement

and if it showed that everything is working fine,
put this code inside ur page:

do until News.EOF
response.write News.Fields("Chart") & "<BR>"
News.MoveNext
Loop

This way u make sure 100% that ur data is neing retrieved correctly

Hope it works,
Please tell me what happens with u,

Best Regards
Firas S Assaad
0096892166434
firas489@gmail.com
ASP/VBscript Developer


*** Sent via Developersdex http://www.developersdex.com ***

Re: Response.Write Text with DataField by robertsims

robertsims
Wed Apr 12 12:51:10 CDT 2006

Thanks for the advice. I tried all that you said, with no luck.
However, here is what I attempted and it worked (somewhat anyways).

<%
Response.Write "<img src='" &
News.Fields("Chart").Value & "'>"
%>

As you can see, I removed the If statement and left the last write in.
It worked. I put the If statement back in and it quit working. Any
ideas?


Re: Response.Write Text with DataField by robertsims

robertsims
Wed Apr 12 13:08:06 CDT 2006

It appears that the IF statement is causing the problem. I changed the
code to this:
<img src="<%
If (News.Fields("Chart")) <> "" Then
Response.Write News.Fields("Chart") & "..."
Else
Response.Write ".\imgs\nochart.jpg"
End If
%>" />

Now on records 1 and 3, the output is: <img src="..." />

Strange that it is dropping the datafield yet the IF check is working
properly.


Re: Response.Write Text with DataField by Firas

Firas
Thu Apr 13 05:16:40 CDT 2006




I Have been thinking about it lately, and i had an idea, which most of
the times works.

Change your Query, so that it will only retrieve the records that Chart
Field doesnt equal to nothing

It will look something like that

"SELECT * FROM table WHERE Chart is not null"


Hope this works,
Tell what happens



Best Regards
Firas S Assaad
0096892166434
firas489@gmail.com
ASP/VBscript Developer


*** Sent via Developersdex http://www.developersdex.com ***