Random Database Results

I am using the following code to Query information from my db table. The problem I have is that it displays the whole table rather than displaying 5 random results by ProductID.

<%
objConn2.open strconn2
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open "SELECT * FROM Products", objConn2

Do While Not objRS2.EOF
Response.Write ":: <a href=""productsDisplay.asp?ProductID=" & objRS2("ProductID") & """>" & objRS2("Product_Description") & "</a><br>"
objRS2.MoveNext
Loop
objRS2.Close
objConn2.Close
Set objConn2 = Nothing
%>

View Replies


ADVERTISEMENT

Select Random Row In Database

does exist any command to get random row from target table in target database and then use this row ?

View Replies View Related

Random Database Records

I'm trying to create a portion of script that would select x (variable) number of random records from a table.

in PHP, I could do this pretty simply with a line like, "select * from table order by rand() limit x", but the solutions I've seen so far for asp and access involve things like 40 lines of code, selecting the entire contents of a database, creating temporary tables, etc.

Is there any quick and dirty way of doing this?

View Replies View Related

Random Values From Database

Suppose I have a table named as tblfriends and there are 3 columns with several row. Column names are: name, email, phone

I want to pick 5 names randomly from the table each time my asp page refreshes. How can this be coded in classic asp?

View Replies View Related

ASP Database Results

I have created a small script that will read from a related products table then display the products associated with it. However I am only getting it to return one product even though I have multiple listed. Here is the code I am using: Code:

View Replies View Related

Inserting Random Passwords Into Database

I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program generating the 327 passwords, but have had no luck inserting them. Code:

View Replies View Related

How To Choose A Random Record From A Database

ill have a database with 1 table and 3 fields:

ID FIRSTNAME LASTNAME

(the ID field will be the auto incrementing index)

there might be 10 records in the DB, there might be 10,000. i need to open the DB and randomly select a record (and then display the name, which i dont have a problem with)

how can i randomly select a record? im guessing id have to open a recordset and check the count to get the number of records, so lets say there were 100 records. i imagine i would have to generate a random number between 1 and 100....

View Replies View Related

Random Quote From A Database Every 4 Days

obviously in standard asp. and i'm not even sure where to begin. I currently have it set up for a random quote every time a user refreshes the site. This was no problem. Any help or if you can point me in the right direction.

View Replies View Related

Generating A Random Code Which Is Not In Database

I am trying to write a script that generate random code which are not in database.

Things are ok on these points:

1. Generating a random code

2. Controlling whether it is in database.

For now, if the code is in database, it gives a message.

What I want the funstion do is to generate a code which is not in db?

How can id do this?

I write the code as reference.....

View Replies View Related

Selecting Random Records From Database How?

The following code should select the specified number of records randomly from the database .....

View Replies View Related

Fetch Random Database Table

There are 26 prizes available in a competition a client is running and he wants to be able to select these at random.

I thought the best way of doing this would be to construct a simple ASP page which displays 26 random records from the database.

The fields I wish to display are called name, email and address, and these are located in the table called Competition (this is an MS Access db).

View Replies View Related

Formatting Database Results

I have a query that i have been having trouble with for some weeks and i am desperate to get working.

What i want to do is construct a statement from the values i pull from the database.

for example, i have 2 rows in the database, one field, called dbValue that has the values "Value 1" and "Value 2"

I want to pull the values from the database and construct an if statement like the following

if testing = Value 1 OR Value 2 then
else
end if

Could someone please help me out, the values have to be pulled from the database as they will be dynamic.

View Replies View Related

Stripping Down Database Results

i have a record that is returned by the database as domain/username. i want to be able to strip off "domain/" and just display "username". is this possible? if so, how would i go about doing this?

View Replies View Related

Comparing Database Results

I have two variables

DIM medical_crew_1
DIM crew_name

One was created by joining the results of a database query

'first connect and query the first database table ........

objRS("first_name")
objRS("last_name")

crew_name = objRS("first_name") & " " & objRS("last_name)

I am comparing this variable with the second variable which comes from a
seperate table in the same database Code:

View Replies View Related

Database Results Buttons

How can i change the query results buttons (Start, Next, Previous,End) in asp?

View Replies View Related

Pull Database Results

I'm not sure if this is possible or not, but I thought some one here should be able to tell me how it can be done. I'm building a site that will allow people to enter information about their company into a database, the information is then displayed in a profile page for them. They can enter things like news and events. This all works fine and dandy, but now I have had an idea.

Is it possible to be able to publish something for each company so that they can display the same information on their own website? I am thinking it would be something similar to an RSS feed.

Has anyone done anything like this before? The site right now is ASP with a MSSQL backend. The sites that will be posting the published information may be a variety of hosting platforms, if a certain platform is required then we will make it as a requirement.

View Replies View Related

Random Display Of Images Dynamicly From Database

I am trying to retrieve images from the database and display them in a random order. The order of the images is supposed to change each time page is refreshed.

Below is my code, I am using an array to store the images but the images are not displayed for some reason. Any help would be appreciated.

<% Dim rstResult
Dim strSQL
Dim img(100)
imgID = 0
set rstResult = Server.CreateObject("ADODB.Recordset")
strSQL = "sp_sel_TilesByType 'O'"
rstResult.Open strSQL, strConnect

set rResult = Server.CreateObject("ADODB.Recordset")
sSQL = "sp_sel_TilesByType 'O'"
rResult.Open sSQL, strConnect


if not rResult.EOF then

do while not rResult.EOF
response.write("hi")

imgID = imgID + 1
img(imgID) = "images/tiles/" & rResult("TileImage")
response.write(img(imgID))
rResult.movenext

loop
end if

if not rstResult.EOF then
intVendorID = 0
do while not rstResult.EOF


if intVendorID <> rstResult("VendorID") then
rndNumber = RandomNumber(imgID)
Response.Write "<p>"
Response.Write "<a href=javascript:popWin('tileview.asp?" & rstResult("TileID") & "','',1,1,1,1,700,600);>"
'Response.Write "<img src=images/tiles/" & rstResult("TileImage") & " border=0>"
response.write(rndnumber)
Response.write "<img src=img(rndNumber)>"
Response.Write "</a>"
Response.Write "</p>"
end if
intVendorID = rstResult("VendorID")
rstResult.MoveNext
loop
end if
set rstResult = nothing%>

View Replies View Related

Returning Random 10 Records Form A Database?

How can I do it?

View Replies View Related

Writing Array Of Random Numbers To A Database

I am trying to write an array of random numbers to a database. The array part is working fine, but when I go to update the dataabse, it inserts the last value of the array into all the fields in the database .....

Dim MyValue,sqlRandom
Dim arrayRandom(8)
for i = 1 to 8
Randomize
MyValue = Int((100 * Rnd) + 1)
arrayRandom(i) = MyValue
response.write "<p> Array Value:" & arrayRandom(i)

sqlRandom = "UPDATE CarParkDetails SET FreeSpaces = '" & arrayRandom(i) & "'"
Conn.execute(sqlRandom)

next

I can't see whats wrong!

View Replies View Related

Presenting Database Results In A Repeater Control

I am using a repeater control to display the results of a database query. The problem is when outputing the results of a multiline nvarchar field.

I generally try put it in a <pre> tag and try to enforce the table width. However this doesn't help and the table width when viewing the page is the width of the page, and not the specified width. Code:

View Replies View Related

How Do I Make Random Images Not Random?

However, what I want to do is include a request.querystring("ID"), so that IF an ID is defined, eg ID=3, , it will display the relevant (not random) information. I've tried this every way I can think and get type mismatches, etc etc. It's probably really simple but I can't see it.

<%
limit=3
redim link(limit)
redim image (limit)

link(1)="xxx"
image(1)="image1.jpg"

link(2)="xxx"
image(2)="image2.jpg"

link(3)="xxx"
image(3)="image3.jpg"

randomize
random=int(rnd*limit)+1

%>
<center>
<a href="<%= link(random) %>">
<img src="<%= image(random) %>" border="0"></a>

View Replies View Related

Making It Random (getting Random Numbers)

I just wanted to know whats the best way to generate 50 or say X amount of number at random without having to repeat any of the previous number...

so far I've the following:

[VBS]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
function RandomNumber()
dim theRandom

Randomize
'RandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

theRandom= Int((99 - (0) + 1) * Rnd + (0))

if (theRandom<10) then theRandom = "0" & theRandom

RandomNumber = theRandom
end function
%>[/VBS]

and then I've this in the body of HTML doc: Code:

View Replies View Related

Random Token Generator - Not Really Random

We have the need to have a random token (a 16 char alphanumeric field) to be used as the key for one of our SQL tables. I have created a random token generator, however after only 3 months in production, it appears that we had an instance where a token that already existed in the tables was created. There are 3810 records currently in the database so it isn't like there are billions of records there.

I contacted an old college buddy of mine who is a mathematician, and he claims, assuming that random really does mean random, that the chances of getting a duplicate token are 1 in 79.5 septillion (79,500,000,000,000,000,000,000,000).

So my conclusion is that this was either a complete freak of nature occurance, or my random generator isn't really all that random. Here is the code behind how I am generating this: Code:

View Replies View Related

Random Number Not Random

I am trying to generate a random number. I am using randomize and then rnd to return a decimal number between 100 and 120. This will give me a longitude. I am doing something similar to generate a latitude.

I created this on a page which refreshs every minute. I put these points into a map and they are showing up in groups of straight lines. Since rnd is time based will refreshing every 60 seconds return similar numbers?

View Replies View Related

Random Row

I want to display data of a Random Member on my page.. and I did a search in these forums and I tried to do this:

[CODE] SELECT tblMiembros.*, tblDatosPersonales.*
FROM tblMiembros, tblDatosPersonales
ORDER BY rnd(isnull(tblMiembros.ID_APLICANTE) * 0 + 1)"[/CODE]

This doesnt throw any errors. but it always displays the same row... (first in database)

am I doing something wrong? am I missing something?

View Replies View Related

Regarding Random

I have a client asking me about random images on his site, basically I am using the following code:-

<%
 RANDOMIZE
 Response.write("<IMG SRC='../gfx/bg-img0" & INT((3)*RND()) & ".jpg'>")
 %> 

Agreed its not the best code, but he is finding that the same image could be repeated like three times in a run.

I have an include file which displays the image, and the random script is placed inside that include. So when he is going from page to page this is where the issue lies.

Can anyone help me out here, is it even possible to have a different image load each time, and not have them repeating.

View Replies View Related

Random Value

I am using random number to be used as a unique identifir. Since random numbers are in decimals I am using going to convert it into an integer and since I need to append this Id into my URL, I am converting it into a string. SO my formula looks like this.

CStr(Int((Highest-Lowest+1)*Rnd+Lowest))

S0 now every time a new record is generated would this formula generate a unique number for unique identification in the table. I can't see how it can do it. Say A user is assigned a random number; then another user subscribes so how would the server determines that the random value assigned to next user is not already assigned to any other user.

In case if this can't work (a unique ID for every user) then I'll stick to this very same formula and after the random number is generated, I'll check this number with the table in the database and see whether it's been assigned already. If yes, I'll request another random value, if not then I'll go with it. Is this the right strategy?

View Replies View Related

Random Image

I have done random image display with the help suggestion from this discussion form. now I want to provide link on each image. i.e. all the images display randomly, should have different link. is it possible? if yes, how?

View Replies View Related

Random Images

is there sombody who can helpme witht he following, i am ''pretty new'' to
php and am looking for a script to show images randomly at a 10/ 15 seconds
interval. is there anybody who can help me with this or does know where to
find a good template script for this?

View Replies View Related

Random Image

example:

When u see some sites ,
the advetisement images are changing ,

when ever the browser is refreshed...

.....

like tha i want to do that.....

View Replies View Related

Random Image

I have the below ASP function to display a random image from a folder.

<%
Function RandomImage(strPath)
Randomize()

If Right(strPath, 1) <> Chr(47) Then strPath = strPath & Chr(47)
strPhysical = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:Inetpubwwwrootpag-siteimages
andoms")
Set objFiles = objFolder.Files

For Each objFile in objFiles
strFile = LCase(objFile.Name)
strFiles = strFiles & strFile & vbTab
Next

strImages = Split(strFiles, vbTab)
If UBound(strImages) > 1 Then
RandomImage = strPath & strImages(Int(Rnd(1)*UBound(strImages)))
End If
End Function
%>

and this places the image in the HTML

<img name="Intropic" src="<%=RandomImage("images/randoms/")%>" width="211" height="158" alt="" />

but sometimes the script places a ._ before the image file name in the outputted HTML?

View Replies View Related

Getting Random Errors

I'm afraid I have a technical problem here. Basically what happens is that I'm getting some random errors(like Type mismatch... etc) that shouldn't under normal circumstances occur. Then I connect to my server via remote desktop and Recycle the application pool on which my asp pages run. Errors then disappear

View Replies View Related

Random ASP File?

I have a file where i want to call a random asp file using the "include file" statement. I know it can be done with images, but can it be done with other asp files? and how?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved