Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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 April 3rd, 2006, 09:58 AM
Registered User
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Flagging a Random Record

I am using the following select statement to randomly select a single row.


What I need to do is flag this record so it won't be randomly selected the next time I run the above query. I know I need to add a where clause to the above statement. How do I insert a value into the bit data type I am using in that where clause when the record is being randomly selected.

I am using ASP.NET 2.0 and Visual Basic. I think I might need a statement like this in my code behind:

Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEv entArgs) Handles SqlDataSource1.Selecting
        SqlDataSource1.UpdateParameters("Flag").DefaultVal ue = "True"
    End Sub

And here is what I am working with as a datasource

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ MYCONNECTIONSTRING %>"
        SelectCommand="SELECT TOP 1 * FROM [TBL_Example] ORDER BY NEWID()"
        updatecommand="UPDATE [TBL_Example] SET [Flag] = @Flag">
            <asp:Parameter Name="Flag" Type="boolean" />

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random record from objRS - why is EOF or BOF True? jfrizelle Classic ASP Databases 0 February 5th, 2008 07:24 AM
creating flagging system Pawan Sharma VS.NET 2002/2003 0 September 12th, 2006 02:05 PM
Display a random record for 24 hours palvin SQL Language 6 February 6th, 2006 10:36 AM
display random record from access database jialin PHP Databases 1 December 2nd, 2005 09:18 PM
Random Table/Field/Record Ravenwillow VB Databases Basics 10 August 18th, 2005 08:10 PM

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