473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Showing random recordsets

347 100+
I have a webpage that i want to show 6 random recordsets from the same database each of the records in the database has a unique number between 1 and 156 i can get the asp to return the random numbers and response.write them to the page, the problem i am having is getting it to show that name and picture of each person

here is the code i am using to generate the random selection, only 1 at this time
Expand|Select|Wrap|Line Numbers
  1.  
  2. <% 
  3. randomize
  4. random_number1=int(rnd*156)+1
  5. %>
  6. <%
  7. On Error Resume Next
  8.  
  9. Response.Expires=0
  10. Set yaketyConnection=Server.CreateObject("ADODB.Connection")
  11. DatabaseDetails="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("../private/yakety.mdb") & ";"
  12. yaketyConnection.Open DatabaseDetails
  13. yaketyQuery="SELECT * FROM celebs WHERE rndnumber='%"&random_number&"%'"
  14. Set yaketyRecordset=yaketyConnection.execute(yaketyQuery)
  15. %>
  16.  
This is the code i am using to try and write the info to the webpage
Expand|Select|Wrap|Line Numbers
  1.  
  2. <DIV id="rnd1" class="rnd1"><img src="Pix/<%=yaketyRecordset("image")%>" width="100" height="100" alt="<%=yaketyRecordset("firstname")%>&nbsp;<%=yaketyRecordset("surname")%>"></DIV>
  3.  
If someone could help it would be appreciated
May 15 '08 #1
8 1589
jeffstl
432 Expert 256MB
So when you say the picture and name doesnt show are you getting an error? Or is it just a blank page?

Your query syntax be like this

Expand|Select|Wrap|Line Numbers
  1. yaketyQuery="SELECT * FROM celebs WHERE rndnumber=" & random_number1 & ""
  2.  
You were missing the 1 at the end of random_number as you have it defined.
You also need to use the =" & var & " syntax for a numeric value. The % sign only used for LIKE statements, and you dont need single quotes for numbers only strings.
Also rndnumber should be an integer in your table design if its not for this syntax.
May 15 '08 #2
colinod
347 100+
i am getting an error on page and when i look at the code it is not writing the information contained in the asp code bits the page error says object expected
I dont think the error is anything to do with the code to write the asp objects to the page as it still comes up when they are removed it only dissapears when the connection code at the top of the page is removed i have attached a copy of the file or it can be seen at www.yaketyyakallmouth.com
May 16 '08 #3
colinod
347 100+
Have now fixed the error nothing to do with asp is all thats happening now is that the image name variable from the asp code is not showing so the image is missing this can be seen at www.yaketyyakallmouth.com/index2.asp
May 16 '08 #4
DrBunchman
979 Expert 512MB
What do you mean the variable is not showing? Is the value not being passed to the images src property?

Dr B
May 16 '08 #5
colinod
347 100+
yesy that right in the produced code is all i get is

<DIV id="rnd1" class="rnd1"><img src="Pix/" width="100" height="100" alt="&nbsp;"></DIV>
May 16 '08 #6
DrBunchman
979 Expert 512MB
Is this field definitely populated in the database?

If you try a simple loop through all the records and response.write this field to the screen does it display properly?

Dr B
May 16 '08 #7
colinod
347 100+
i have many other pages collecting the same information from the database all being returned correctly the ather pages ar all done with response.write asp code i am now tring this but i get the div tags that contain the asp coming back empty

Expand|Select|Wrap|Line Numbers
  1. <div class="rnd1">
  2. <% Response.write("<a href=""everyone.asp?id=" & yaketyRecordset("idnumber") & "&voicetype=" &voiceid &""" target=""_top""><img src=""pix/" & yaketyRecordset("image") & """ width=""100"" height=""100"" border=""0""></a>" & vbNewline) %>
  3. </div>
  4.  
Returns

Expand|Select|Wrap|Line Numbers
  1. <div class="rnd1">
  2.  
  3. </div>
  4.  
May 16 '08 #8
DrBunchman
979 Expert 512MB
So your server code isn't creating any mark-up at all? If you put a simple:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <% Response.Write("<p>Hello World!</p>") %>
  3.  
on the page does it display that?

EDIT: Just had a thought: your error trapping may be preventing you from seeing the real problem. If you remove it what happens?
May 16 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Paul Rubin | last post by:
http://www.nightsong.com/phr/python/sharandom.c This is intended to be less predicable/have fewer correlations than the default Mersenne Twister or Wichmann-Hill generators. Comments are...
1
by: rob | last post by:
Hey, I've got an Classic ASP app pulling some records out of a DB, which worked fine when it was Access. When we upped to SQL Server, all of a sudden, when the Recordsets came back, all the...
1
by: polilop | last post by:
I have a query to a database that returns some recordsets. What i need to do is pick 5 random recordsets from those retreved from the query???
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
11
by: Jeff | last post by:
het gang. Happy Holidays and stuff. Here is what I am wanting to do, but need some guidance as hwo to start in the right direction. using sql db on ms server i have players sign up for a...
10
by: Joey_Stacks | last post by:
Does anyone know of a scipt that will rotate random div layers on page refresh? I have a primary content area front and center on my site homepage, and I'd like to rotate various chunks of html...
47
atksamy
by: atksamy | last post by:
Hi, I am trying to compare two recordsets. the first rs1 has random records. The second rs2 has the standard values for those records. Initially I am looking to take each of the records and see if...
2
by: Millie88 | last post by:
I am getting an error on the random.js var size and no tip is showing. Any help is appreciated! <html> <head> <!-- The Home Center Filename: home.htm
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.