Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2004, 10:57 PM
Registered User
 
Join Date: Mar 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with random records

im trying to generate a random record from my database using an oledbconnection. my code is shown below where i genereate a random number, match the number to a "QuestionNo" field in my database, and then try and get it to print out the record. but so far i can get it to generatea random number, but i dont kno if it is matching it to the Table and i cant get it to print out. please help.....

Dim objConnection as New OledbConnection(strConnection)
Dim strSQL as string

objConnection.Open()

Dim t as integer
Randomize
t = CInt(Int((10 * Rnd()) + 1))
example.InnerHtml = "Random Number : " & t



strSQL = "SELECT * FROM Table1 WHERE QuestionNo = " & t &""



Dim objCOmmand as New OledbCommand(strSQL, objConnection)

objCommand = New OleDbCommand(strSQL, objConnection)

objCommand.ExecuteNonQuery()

objConnection.Close()


Dim objDataReader as OledbDataReader

objConnection.Open()

objConnection.Close()

response.write (strSQL)

end sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
csv with multiple records in random order biztalk xs2bharat Biztalk 0 May 2nd, 2007 07:09 AM
ongoing problem with random records....HELP! ps124 ASP.NET 1.0 and 1.1 Basics 0 March 26th, 2004 05:35 PM
Generating 5 unique random records from a database ps124 ASP.NET 1.0 and 1.1 Basics 2 March 8th, 2004 05:59 PM
random records from database HammR PHP Databases 1 December 11th, 2003 02:03 PM
Random Numbers not so random... katsarosj ASP.NET 1.0 and 1.1 Basics 5 November 20th, 2003 12:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.