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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying datatype text

Status
Not open for further replies.

s4dadmin

Programmer
Apr 27, 2003
107
US
I have an event database in sql server 2000 with a phone number field with datatype text and it will not display in my asp page and i am not sure why. I know there is some data in the table because I entered a few events. Can someone help?
Here is the code
Code:
strPhone1 = rsEvent("eventPhoneContact1")
strPhone2 = rsEvent("eventPhoneContact2")

<%if strPhone1 <> "" Then%><%=strPhone1%><br /><%End If%>
<%if strPhone2 <> "" Then%><%=strPhone2%><br /><%End If%>

Quincy
 
Ouch, it looks like it should work, maybe your not getting back any of the records with phone number?

Also, it might be a little more efficient to do this:
Code:
<%
If strPhone1 <> "" Then Response.Write strPhone1 & "<br>"
If strPhone2 <> "" Then Response.Write strPhone2 & "<br>%>

I'm not sure how two concatenations stands up against breaking it into 6 code blocks, but it is definately a lot easier to read.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
oops:
Code:
<%
If strPhone1 <> "" Then Response.Write strPhone1 & "<br>"
If strPhone2 <> "" Then Response.Write strPhone2 & "<br>"
%>

Sorry, corrected my little example.

-T
 
I tried your example and nothing is displayed. I am doing queries on the database so I know the data is there. Here is the modified code
Code:
 strQuery = "SELECT eventTitle, eventDescription, eventURL, eventStartDate, eventStartTime, eventEndDate, eventEndTime, eventLocationCity, eventLocationState, eventPhoneContact1, eventPhoneContact2, eventEmailContact, eventAddress1, eventAddress2, eventZipCode FROM tbl_Events WHERE eid = " & intEvent & ";"
 
rsEvent.Open strQuery, adoCon

strPhone1 = rsEvent("eventPhoneContact1")
strPhone2 = rsEvent("eventPhoneContact2")

      if strPhone1 <> "" or Null Then Response.Write strPhone1 & vbCrLf
      if strPhone2 <> "" or Null Then Response.Write strPhone2 & vbCrLf

The data is displayed in a textarea form field. The only difference with the data is that the other data is in a varchar datatype and the phone numbers are in a text datatype.

Quincy
 
have you tried testing by just

If NOT rsEvent.EOF Then
Response.Write "Phone Value " & Len(rsEvent("eventPhoneContact1")) & " End Value"
End If

___________________________________________________________________
[sub]
onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811
[/sub]

 
I just tested it and everyone of the entries reads 0 length. If I changed the datatype from text to varchar would that damage the data.

Quincy
 
No, in fact varchar would probably be better. text types occasionally have issues in conversion by the drivers (which this may be) and they also have a fixed length whih means they will space pad any string they contain to be th gith length. varchar on the other hand only pass back the string they hold with no padding. There shouldn't be any problem switching the field to varchar (as long as you keep the length acceptable).

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top