vbscript recordset not displaying

I am pulling a recordset from a database.
I am having a problem that all my fields populate until a certain point .
then the rest don't load.
I am trying to figure out if there is a way to display the field in a way that whatever is returned doesn't break the script on the rest of the page.

My code says this:'  <% response.write(stateinfo.Fields.Item("middleContent1").Value) %>

it is returning:
 //farm7.staticflickr.com/6144/5934795219_dd7aa11f1a_n.jpg

Open in new window


why would that code stop the next one from displaying?
rivkamakAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
What is your code? One line doesn't help.
Scott FellDeveloper & EE ModeratorCommented:
If you have too much data, you may be timing out.  


Try this

<%
' your create your sql and recordset here
' Let's say you call the recordset rs
MyArray=rs.getrows()
rs.close
%>
<div>
<%
'notice you can close the rs here then use the array throughout your code without accessing the db
for r = LBound(MyArray, 2) To UBound(MyArray, 2)
    	ID= MyArray(0, r)
	Image = MyArray(1, r)
	Description = MyArray(2, r)

        response.write "<img id=""img_"&ID&"""  src=""&Image&"">

      response.write "ID= "&ID&"<br>"
next
%>
</div>

Open in new window


Using getrows will put all of your data in an array and will be much faster.  You still don't want more than a 100 rows of data out put.
rivkamakAuthor Commented:
Here is the full code
Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection =  myConn
Command1.CommandText = "select * from stateInfo where stateInitial= '" &  session("stateName") & "'"
Set stateinfo = Command1.Execute
  stateLong = (stateinfo.Fields.Item("stateLong").Value)
  statePhone = (stateinfo.Fields.Item("phoneNumber").Value)
middleContent = (stateinfo.Fields.Item("middleContent1").Value)
fullname = (category.Fields.Item("name").Value)
ListCity = stateinfo.Fields.Item("listofCities").Value

map = stateinfo.Fields.Item("iframeMap").Value

Open in new window


all the information after middleContent don't tabulate.
It doesn't throw an error, I have the real data and I know there is really text in all of them.
and I put in my first quote what was returned in that middleContent
Get Blueprints for Increased Customer Retention

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

GaryCommented:
What db is this?
Are any of those fields a blob field (depends on the db what is called but it would be a very large text field)
Scott FellDeveloper & EE ModeratorCommented:
Can you run this on your server?  I wonder if you are actually getting an error and asp errors are turned off so you are not seeing the actual error or it is hidden.  Try viewing your source and look to see if you have an error code at the bottom of your page or are you getting the closing html tags?  If you are getting a 500 error, you will either need to surf this page on your server or turn on asp errors in iis.

You can also try running your code and one by one commenting out the lines below middleContent and see which is giving you the problem.

Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection =  myConn
Command1.CommandText = "select * from stateInfo where stateInitial= '" &  session("stateName") & "'"
Set stateinfo = Command1.Execute
  stateLong = (stateinfo.Fields.Item("stateLong").Value)
  statePhone = (stateinfo.Fields.Item("phoneNumber").Value)
middleContent = (stateinfo.Fields.Item("middleContent1").Value)
'fullname = (category.Fields.Item("name").Value)
ListCity = stateinfo.Fields.Item("listofCities").Value

map = stateinfo.Fields.Item("iframeMap").Value

Open in new window

Big MontyWeb Ninja at largeCommented:
its a bad idea to do

select *

in your sql statements, it eats up memory and is not very efficient. Instead, try listing out the fields you actually want. This is especially true for tables with a large amount of columns.

sql = "select stateLong, phoneNumber, middleContent1, [name], listOfCities, iFrameMap from stateInfo where stateInitial= '" &  session("stateName") & "'"
Command1.CommandText = sql

also, the column "name" might be a reserved word, depending on your database type
rivkamakAuthor Commented:
@Big Monty, I'm sorry but I used select * because I am using every single field this time.

@: cathal, yes one of my fields (ListCity ) is a varchar (max) but I dont' think that should make a difference since it's not the one causing a problem.

@Scott Fell (padas), I took your advice and I put the code on it's own page, writing each line out.

You can view it here:

http://www.kars4kids.org/test2.asp

In this order all the fields show.

If I switch the order around on this page: http://www.kars4kids.org/test3.asp
 and move the flikr link higher up,  then the middle content underneath doesn't load anymore.
It's not erroring, it's the exact same names as the other page.

Any ideas why the rest of the fields aren't displaying?
GaryCommented:
Change your select to select them in order with the ListCity as the last item.
This is a vague memory from using ASP years ago that blob fields caused problems in a recordset if they were not the last item.
Scott FellDeveloper & EE ModeratorCommented:
Do you have On Error Resume Next in your code?  If so, for now take it out.

<% On Error Resume Next %>

What is the exact code you used to generate each of those pages?

Something is not right in coding or how data is stored.

Look at link 1.  There is an odd </ hr> tag with line brakes.
<br>faqLink = http://www.flickr.com/photos/kars4kids/5934795219/in/set-72157627062996115
</ hr>

<br>

Open in new window

In link 2 it is not there
<br>faqLink = http://www.flickr.com/photos/kars4kids/5934795219/in/set-72157627062996115<br>

Open in new window

After the </ hr> code on the first link, I can see code but not on screen
<br> stateLong:Alabama<br> statePhone =(205) 918-8499<br>ListCity = <br>address = 1401<br>city = denver<br>faqImage = //farm7.staticflickr.com/6144/5934795219_dd7aa11f1a_n.jpg<br>faqLink = http://www.flickr.com/photos/kars4kids/5934795219/in/set-72157627062996115<br>addressZip = 80204<br>middleContent1 =   <h5><strong>Coat Giveaways with Mayor Cory Booker</strong></h5><br>middleContent2 =   <h5><strong>ChillZone</strong></h5><br>middleContent3 = <h5><strong>Grover Cleveland Middle School</strong></h5><br>iframeMap = <iframe width="287" height="232" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps/ms?msa=0&amp;msid=214140032623940315677.0004d7d2b4481642f1e5e&amp;hl=en&amp;ie=UTF8&amp;t=m&amp;ll=42.811522,-75.849609&amp;spn=7.478448,12.612305&amp;z=5&amp;output=embed"></iframe><br>titleNeccesary = False<br>titleCounties = a,b,c,d,e,

Open in new window


Notice the space in the br tag
<br> stateLong:Alabama<br> statePhone =(205) 918-8499<br>

Open in new window

This is what I meant before about white space.

In any case, when I view source, there is no data in the 2nd so something must be going on before it renders to the screen and you have not given us that code.
rivkamakAuthor Commented:
sorry, here is my code:
<%
session("stateName") = "AL"
Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection =  myConn
Command1.CommandText = "select * from stateInfo where stateInitial= '" &  session("stateName") & "'"
Set stateinfo = Command1.Execute

response.write("<br> stateLong:" & stateinfo.Fields.Item("stateLong").Value)
response.write("<br> statePhone =" & stateinfo.Fields.Item("phoneNumber").Value)
response.write("<br>address = " & stateinfo.Fields.Item("address").Value)
response.write("<br>city = " & stateinfo.Fields.Item("addressCity").Value)
response.write("<br>addressZip = " & stateinfo.Fields.Item("addressZip").Value)
response.write("<br>faqImage = " & stateinfo.Fields.Item("faqImage").Value)
response.write("<br>faqLink = " & stateinfo.Fields.Item("faqLink").Value)
response.write("<br>middleContent1 = " & stateinfo.Fields.Item("middleContent1").Value)
response.write("<br>middleContent2 = " & stateinfo.Fields.Item("middleContent2").Value)
response.write("<br>middleContent3 = " & stateinfo.Fields.Item("middleContent3").Value)
response.write("<br>iframeMap = " & stateinfo.Fields.Item("iframeMap").Value)
response.write("<br>titleNeccesary = " & stateinfo.Fields.Item("titleNeccesary").Value)
response.write("<br>titleCounties = " & stateinfo.Fields.Item("titleCounties").Value)
response.write("<br>ListCity = " & stateinfo.Fields.Item("listofCities").Value)

%>

Open in new window

Scott FellDeveloper & EE ModeratorCommented:
I wonder if you have some code in the content that is messing with the output.

For each item, can you change

response.write("<br>middleContent1 = " & stateinfo.Fields.Item("middleContent1").Value)

Open in new window

to

response.write("<br>middleContent1 = " & showCode(stateinfo.Fields.Item("middleContent1").Value))

Open in new window

And place this function on your page
function showCode(x)
    showCode = replace(x,"<"," < ")
    showCode = replace(x,">"," > ")
   showCode = replace(x,"'","*single quote*")
   showCode = replace(x,chr(34),"*dbl quote*")

end function

Open in new window

I want to see if there is some code you may have that is generating some html
Robberbaron (robr)Commented:
I would also add a length check to test both of them.... and convert to string to be sure.

dim middlecontent as string, faqlink as string
faqlink = stateinfo.Fields.Item("faqLink").Value
middlecontent1 = stateinfo.Fields.Item("middleContent1").Value
response.write("<p>Testing: faqlink=" & str(len(faqlink)) & "; middlecont=" & str(len(middlecontent1)) & ";</p>")
response.write("<br>faqlink " & showCode(faqlink))
response.write("<br>middleContent1 " & showCode(middlecontent1))

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rivkamakAuthor Commented:
The page is here: every field has content, but it's not loading, not causing an error:
http://www.kars4kids.org/test3.asp

@Scott Fell (padas), i put your showcode around each field. it didn't help.

yes, when I tried this @robberbaron len, whatever I referenced for the lenght, even though it just returned the number, it displays later as the text on the page.

How come?
rivkamakAuthor Commented:
If I take this line and put it on the bottom after all the other displays I get a len of 0
if i move to the top line, I get a len of 75, but nothing displays under it;
response.write("<br>faqLink = " & len(stateinfo.Fields.Item("flikrLink").Value))
rivkamakAuthor Commented:
after spending alot of time on this, I discovered if I keep the fields listed in the order of the database, all the information loads. If I switch the order , the fields come back empty.
I'm closing this ticket, but if anyone has information on why it's this way, i'd be happy to hear.

Thank you all for your help.
Scott FellDeveloper & EE ModeratorCommented:
It does not make sense that ordering the fields is a true fix.  The only thing I can think of is there must be some content in the database that either has some html or odd character that is preventing display of the remaining content.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.