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


ADVERTISEMENT

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 Numbers

I have a problem creating random numbers. I basically have this

Randomize()
iRandom = Int(10 * Rnd + 1)

If I do not wait a few sec before hitting the page again it will create the same random number as generated a few seconds before.Any idea why it is like that? Another way to reprocess the "bug" is to just fit F5 few times in a row and you end up with the same number being generated. Its annoying and I need some help to "fix" it!

View Replies View Related

Random Numbers In C#

I am trying to generate a random number between 1 and 100 into a label, using c#....

View Replies View Related

Random Numbers Access

I am developing a online test application(multiple choice ques) So for that i need to shuffel the questions randomly. eg there will be 60 Questions in total. If say 50 users are connected to it, all will be having same 60 questions but its order should be different.

i am using below code to randomly generate questions numbers but the problem with this code is it is repeating the number.I want to generate non repeatable numbers. Can anyone help me out to do it.

Dim my_num,max,min
Dim i
i = 0
max=60
min=1
For i = 1 to 60
Randomize
my_num=int((max-min+1)*rnd+min)
Response.Write my_num & "<br>"
Next

View Replies View Related

Random Numbers Find

I know thats theres already a few posts about this subject but I need to create 3 random numbers of any size, I've used the following code -:

randomnumber1 = int(rnd*9)+1
randomnumber2 = int(rnd*9)+1
randomnumber3 = int(rnd*9)+1

but it always returns, 7,5 and 6..
Not very random as you can see

View Replies View Related

Random Numbers Select

I have 30 numbers. I need to select randomly 10 out of the given 30. A number must not repeat ( eg. i can't have number 10 twice ). How can i do this??

View Replies View Related

Random Numbers And Letters

I have a code to create a random string of letters. The number of them can be whatever I desire.

what i would like to do, is have it both letters and integers. how would inmodify this code to allow that ....

View Replies View Related

Generate Random Numbers Between 10 And 1,000,000

I am trying to create a random value between 10 and 1,000,000. I am using the following code but it is creating numbers between 10,000 and 999,999. How can I fix it.

<%
Highest=1000000
Lowest=10
Randomize
Val_Rand=CStr(CLng((Highest-Lowest+1)*Rnd+Lowest))
response.write(val_rand)
%>

The code never gives small numbers like 10, 15 500, 250, 257 etc.

View Replies View Related

Allocating Random Numbers

I am using DreamweaverMx to create a football website that stores players to a databse and when they join a game there is a function to randomize a number for each player and store it on a second databse and from the database using sql to link my databases together so that a players details are posted on a page of my website.

View Replies View Related

Random Numbers Based On Points

I have this situation:

each user has some amount of points, for example:

table:users
user_id --- user_name --- points
1 --- user1 --- 100
2 --- user2 --- 100
3 --- user3 --- 100
4 --- user4 --- 200
5 --- user5 --- 500
-------------------
total points: 1000

I want to generate random selection of user, according to their points respectively, so the more points he has, the more likely he will be selected:

user1 in 10% cases
user2 in 10% cases
user3 in 10% cases
user4 in 20% cases
user5 in 50% cases

this percentage is respective to their points; I put some rounded numbers in the example - so total points of 1000 equals 100% - but they can have any amount of points: 1, 200, 3672 etc.

View Replies View Related

Display And Delete Random Numbers

I’m having problems on how to randomiz numbers and delete the ones that have been displayed.

My first step is to take some numbers:

21, 32, 35, 4, 15 and randomize theese so the ouput may look something like this:
35, 21, 15, 32, 4

My second step is to display the first number (35), then when a user clicks on a link I want the second of my random number (21) to be displayed and I also want to delete the first number (35) that has been displayed. And this routine (display number, delete previous number) should continoue untill there is no more numbers. So again, I wnat to step through all my random numbers and delete the ones I have displayed.

Example: ....

View Replies View Related

Test A Random Number For Nearby Numbers

not after code, just thoughts, suppose i'm generating a random 8-digit pin number for our clients, first i'll be checking against the db to see if it already exists before assigning it. what i might do for that is getstring all of the exsiting pins at the top of the script and just keep performing an instr until i get a 0. (i dont expect to ever go above a thousand clients for this system and hopefully my initial number will be random enough that these checks are for backup/redundancy assertion anyway)

but anyway, the main problem is: i dont want to generate a random pin that is one (or maybe two) digit(s) different from another,. i.e.

11111111 is too close to 14115111 and much too close to 11111811. 11121111 is right out of the question as it can be entered as a typo, as is 11111411 because of the numpad

so i'm after thoughts on how to perform that check, i suppose if i went with the "big string of all pins that went before" check i could perform a number of regex searches on the string. i.e.

my pin is 12345678 and i dont want ony to be one digit different so i'd check the string against .2345678 1.345678 12.45678 and so on. think i just answered my own question, anyone else got any ideas? especially for the two digit case (dont want to be performing 36 regex checks do i!)

View Replies View Related

Function To Select 3 Random Numbers Which Are Distinct

I need to generate three random numbers between 1 and 100, but they need to be different.

e.g. 3,43,88 would be fine but 5,76,76 would not.

The function I have to generate a single random number is:

function funRandomNumber(intHighestNumber)
randomize
funRandomNumber = int(rnd * intHighestNumber) + 1
end function

called by: funRandomNumber(100)
Can anyone see how this can be modified to do what I need?

View Replies View Related

Writing Out Array Values

I have an array which has days of the month stored in it. For example at one
time it might have the values

1,2,3,6,7,8,9

at another time it might have the value

4,5,12,14,19,25

These are days of the month that have been selected and read into an array.
What i would like to do is to write them out and put a "X" where the days
were selected Code:

View Replies View Related

Make Array Of Unique Numbers

For a simple search of a help desk application I've written, I'm querying text fields in two tables. One table is full of help desk calls (ids, where they're from, simple description, etc). The other table is full of messages that are related to a call (updates, reasons for closing, etc.) and has the call id as a foreign key.

I've got some sql queries setup to get a list of all call ids that match a search term. Is there a built in way to sort the results to make sure they're unique? I know I could do it manually in a few lines of code but am always looking for the easiest way.

View Replies View Related

DB Random Records From Array

I have read 10000 opinions on returning random records and I am more
confused now that before I started. I have a small access db that will
contain 20 or so rows with 3 or 4 columns. I like to return a set of 6
distinct rows and display the columns in html. I have seen response.write
and loops but can't I throw the 6 random rows in a array and pull the data
as I need it in the page? Examples?

View Replies View Related

Random Images Usin Array

I'm trying to have my program randomly select one of five images. I think my syntax is correct (that is it isn't giving my any error messages and the page loads with the image being replaced by a broken link 'X' box), but I don't know how to display the image to the screen.

Should the response.redirect part automatically display it to the screen or should I have it in some tag like <td><img scr ="lrandom"></td> within my table?

<% dim array(5)
randomize

array(1)="img1.gif"
array(2)="img2.gif"
array(3)="img3.gif"
array(4)="img4.gif"
array(5)="img5.gif"

upperbound=ubound(array)
lowerbound=0
lrandom = Int((upperbound - lowerbound + 1) * rnd + lowerbound)
response.redirect "images/" & (Array(lrandom))
%>

View Replies View Related

Writing To A Database

i am having problems figuring out the syntax used when writing information to a database thru a dropdown.
i have a dropdown w/ all the months listed and i need this recorded into a database where i have already set up a column named "month".
right now all i have is html that says:

Code:

<select name="month">
<option value="January">January</option>
<option value="March">March</option>
<option value="April">April</option>
....... and so on.......
</select>

View Replies View Related

Writing To ASP Database

I cant seem to right to my asp database... This is my code. Code:

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("/db") & "/db.mdb"
ors = Server.CreateObject("ADODB.recordset")
sql = "SLECT * FROM members"
ors.open sql,conn,adOpenDynamic,adLockOptimistic,adCmdText
This is the error message I get...

Object doesn't support this property or method: 'ors.Open'

P.S - I have adovbs.inc included.

View Replies View Related

Problem Writing To SQL Database

I have an asp form that sends data to a redirect page with SQL using JScript. There is a function that I'm using called replace(). The form submits without errors and goes to the redirect page but the data doesn't populate the SQL database. Instead, referrs to the last key ID. Code:

View Replies View Related

Writing Files To A Database

Does anyone know the ASP code for taking a PDF file and a Microsoft Excel spreadsheet and inserting them into an Oracle database?

View Replies View Related

Writing Values To Database.

I'm a newb - so if this is a stupid question, my apologies.

I have a simple form that users fill out and then that info is written to a database. What I'd like to do is perform a calcution on a number and then write those numbers to other records in the database.

So for instance, if someone enters 12 in one field1, it would multiply that by 3 and that would be saved as field2, then mulitply it by 45 and that would be field3, then add field2 and field3 and save that as field4.

I was thiking of passing the form variables to a second page instead of writing them to the database, then using variables in the second page to perform the calculations and then have the second page write all the info to the database, but I thought there had to be a better solution.

View Replies View Related

Writing Records From A Database

After this statement, I want to be able to then show the data in the database in a recordor table view for the user. Any ideas?

'Check if username doesn't already exist
do while not rs.EOF
if rs("username")=Request("Username") then
set rs=nothing
set conn=nothing
Response.Redirect("login.asp?login=createnamefailed")
end if
rs.MoveNext
loop

View Replies View Related

Writing To An Access Database

i would like to write information to an access database. I have tried websites that have scripts but the ones i have saw are fairly complicated. All i have is a form for the user to input information and then i want it to write to a pasific table in microsoft access. how to do this.

View Replies View Related

Writing Multiple Lines Into A Database

When inserting multiple lines into a database asp removes the whitespace so:

hello
all

becomes

hello all

is there any way to detect the return and inset it as intended ie:

hello
all

View Replies View Related

Problems Writing Files To Database

I'm having some problems writing files to my Access database using ASP. I have a table with a couple of fields, one being of OLE datatype, that holds the file. I'm able to write and read small images, but I'm getting corrupted files when I try Word files, and my code is erroring out when I try to writing pdf files.

I think I've found the problem with the uploading of the pdf file (I think I need to adjust some IIS setting to allow larger file uploads), but I don't know what's going on with the word documents. They are small, so upload fine. Does anyone have any experience writing files to Access?

View Replies View Related

Checkboxes In Asp Writing To Access Database?

I am tring to create a front end for this Access Database someone has given me and i have trawled through these and other forums for the answer to my question but have not found anything!!

I have used 4 checkboxes in a form with 4 different names, when i try and create a record in the access database which uses the Yes/No Field Type it displays the error, " Provider error '80020005'

type mismatch" when trying to right the value into the field!

View Replies View Related

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 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 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

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







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