Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading nText with ASP.

Status
Not open for further replies.

QuantumDoja

Programmer
Jun 11, 2004
76
GB
Hi, I am trying to test if a ntext field is empty or not, in my database, the field has some html code in it, when i test the field, it allways comes back as empty...why?

here is my code, tmp is : tmp=Results("Description")

Code:
<% If tmp = "" OR IsNull(tmp) = True OR IsEmpty(tmp) = True then %>
					<img src="red.gif" alt="no text description">
				<% else %>
					<img src="green.gif">
				<% end if %>

 
So the code you have to display is working correctly. Now to find why tmp isn't getting any value.

Lee
 
What happens if you do this:

Response.Write "Length of tmp: " & Len(tmp)
 
Probably it's a memo field, and you are using "Select * " in your sql statement.

Use a field list with the memo field(s) last, Transfer them to a variable straight away.



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
Just a note: this happens with ntext fields. ASP and MSSQL is horrible. It's times like this where MySQL/PHP shows it true colors...

I had the same issue with 3 ntext fields. ASP WOULD NOT show all three. I changed it from "*" to the field names, put them all last, and even out them into variables right away. Until I changed one of them to a varchar 255 (which will only allow 255 chars), it then worked.

Aaron
 
I've run into this problem a lot too. Never had the problem with 3 or more though. We don't have any problem using "*" to select columns, but we do have to put the ntext value into a variable immediately. If you do ANYTHING else with it it will go away. If you're also worried about null values in the ntext data you can handle that at the same time:
[tt]myVar = rs("tmp") & ""[/tt]

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 

Checkout my response to a very similar issue, it may be helpful to this problem: thread333-1131695


A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top