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 %>
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.
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:
(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....
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.
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
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)
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.
We have a fairly large datbase containing thousands of part numbers, product names and pricing. We used to update new pricing changes individually by hand. However, now that our database has grown substantially, I'm wondering what the best method would be to keep the pricing current on our database?
We can obtain new price lists in excel format, however, the part numbers the mfgs use may not necessarily coincide with the part numbers we have. Should I just write some SQL script? Look into using XML? What would be the most efficient way to tackle this problem?
I was playing around in FrontPage and I noticed that you could insert an ActiveX control for a calendar. I would like to be able to use this to integrate with a database - for example, I would like to be able to click on a day of the month and have the page display all data associated with that date (sort of a select * from database where date = "date_clicked_on")
I am trying to add entries in a database together and place the summed value into a text box. Like a total ordered type function for an ecommerce site. I have a field called ArmChairs in my database and based on how many people buy them, I want to know how many I need to have shipped.
I am really struggling with this last bit and would be really appreciative if someone has some code examples.
This is my error in ASP. In my database i am having one field called title which contains some string including spaces . when i get this value into textbox in my web page value is displaying but after space is not displaying .
I want to populate a listbox from a database. This listBox will contain the value of the Table PK. Whenever i chose an ID the input fields in the form below will change corresponding to the PK.
I have a dynamic table asp/vb that is returning records as expected. There are 7 fields that are returning boolean values based on whether there is or is not a meeting on those given days.
My table is returning TRUE and FALSE and all I want to do is create an if or select statement that will detect the values in these fields and change them as follows:
If true, then field = "R" (Wingdings2 R is a checked box) If false, then field = "T"(Wingdings2 returns a x'd out box)
I have a problem with retreiving non repeatable values from database.(this is a shopping cart application)I wrote the query as below,but it didn't work
sql="SET ROWCOUNT 10 select distinct(product_name),pdate from addcart order by pdate desc".
Actually iwant to see recently viewed produts name (max 10) for this iam retrieving values from addcart table. By executing above query iam getting 10 products name but they are repeatable.
I have a form that users use to register with the site. On this form there are checkboxes all with the same name but different values. I am creating another page that will allow users to login and edit their information.
Since all the data from the checkboxes are stored on the database under the same field name and separated by commas; how do I dynamically create a set of the checked checkboxes that the user originally entered along with the other checkboxes the user did not click?
I made a 2 web surveys with identical code. Although the code is similar in both, values on the last page of one of the survey do not go in the database.
I have tried playing around (coz I really dont understand what the problem is), but nothing works. The same code works on the other survey with absolutely no problems.All thats there in my survey to insert values is
.Fields ("fieldname") = Request.value ("name of text box") .update
Any suggestions? If someones willing to help me out quick, I will post my code.
I have a registration form that I'm making and I need to get the count of available spots for each class session. I can't get the array to return something like "0,0,0,0,0,0". Is there a way to do this? There are 6 total classes and they are named 1, 2, 3, 4, 5, and 6.
When you start out, each count will be 0 (meaning no one signed up yet) which makes the openSpots variable equal to 35 (maximum # allowed). Code:
We use an ASP application in which we send out emails using cdo for various events.
At present the email text is hard coded into the code. for example
strMessage = "Dear " & rs("firstname") strMessage = strMessage & "Your request has been approved with reference id " & rs("id")
This causes an administration overhead as everytime the text of the message needs to be changed we need to alter the code to incorporate text or database values.
What we want is to store the message text into a table so it can be altered by the application administrators through GUI by adding the text through freetext entry and field names though a dropdown. Code:
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.
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:
I have certain Keywords stored in a table of the Database.All i need is when ever i find the Keyword in the webpage i need to have a link which opens up as a seperate page and give me the detail information from the database for the seleted keyword.
I have this dynamic array(shown below) that I need to match to values (1 - 10) that I am returning from the database via DSN connection object.
The values I need to match are on the same page (in their own table) but I am not sure how to match up the array indexes to these values. I want to be able to display the array result as part of or nested in another table. Code: