Solved

vbscript recordset not displaying

Posted on 2014-01-09
17
514 Views
Last Modified: 2014-01-21
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
Comment
Question by:rivkamak
  • 6
  • 5
  • 3
  • +2
17 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39769569
What is your code? One line doesn't help.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39769723
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
 

Author Comment

by:rivkamak
ID: 39769743
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
 
LVL 58

Expert Comment

by:Gary
ID: 39769752
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39769790
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 39771209
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
 

Author Comment

by:rivkamak
ID: 39771693
@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
 
LVL 58

Expert Comment

by:Gary
ID: 39771752
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39771827
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
 

Author Comment

by:rivkamak
ID: 39771836
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
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 250 total points
ID: 39791518
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
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 250 total points
ID: 39793579
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
 

Author Comment

by:rivkamak
ID: 39797391
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
 

Author Comment

by:rivkamak
ID: 39797436
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
 

Author Comment

by:rivkamak
ID: 39797804
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39798041
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now