rivkamak
asked on
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.F ields.Item ("middleCo ntent1").V alue) %>
it is returning:
why would that code stop the next one from displaying?
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.F
it is returning:
//farm7.staticflickr.com/6144/5934795219_dd7aa11f1a_n.jpg
why would that code stop the next one from displaying?
What is your code? One line doesn't help.
If you have too much data, you may be timing out.
Try this
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.
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>
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.
ASKER
Here is the full code
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
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
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
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)
Are any of those fields a blob field (depends on the db what is called but it would be a very large text field)
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.
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
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
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
ASKER
@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?
@: 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?
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.
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.
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.
Notice the space in the br tag
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.
<% 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>
In link 2 it is not there<br>faqLink = http://www.flickr.com/photos/kars4kids/5934795219/in/set-72157627062996115<br>
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&msid=214140032623940315677.0004d7d2b4481642f1e5e&hl=en&ie=UTF8&t=m&ll=42.811522,-75.849609&spn=7.478448,12.612305&z=5&output=embed"></iframe><br>titleNeccesary = False<br>titleCounties = a,b,c,d,e,
Notice the space in the br tag
<br> stateLong:Alabama<br> statePhone =(205) 918-8499<br>
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.
ASKER
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)
%>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
ASKER
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>faqLin k = " & len(stateinfo.Fields.Item( "flikrLink ").Value))
if i move to the top line, I get a len of 75, but nothing displays under it;
response.write("<br>faqLin
ASKER
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.
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.
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.