• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 583
  • Last Modified:

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?
0
rivkamak
Asked:
rivkamak
  • 6
  • 5
  • 3
  • +2
2 Solutions
 
GaryCommented:
What is your code? One line doesn't help.
0
 
Scott Fell, EE MVEDeveloper & 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.
0
 
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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)
0
 
Scott Fell, EE MVEDeveloper & 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

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
0
 
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?
0
 
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.
0
 
Scott Fell, EE MVEDeveloper & 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.
0
 
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

0
 
Scott Fell, EE MVEDeveloper & 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
0
 
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

0
 
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?
0
 
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))
0
 
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.
0
 
Scott Fell, EE MVEDeveloper & 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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now