SelectCommand="SELECT TOP 1 * FROM [TBL_Example] ORDER BY NEWID()
I need to, however, flag this record, to determine if it has already been previously randomly selected, and won't take part in future random selections.
I will need to add a where clause to the above, but what I am unsure of is what I should do for the insert statement. I guess I could figure this out on my own as well if I could determine a means to prgramatically store my PK from the above record in session.
Any ideas?I probably need a statement like this in my code behind:
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
SqlDataSource1.UpdateParameters("Flag").DefaultValue = "True"
End Sub
and then I probably need some insert parameters, here is what I am working with right now with my sqldatasource
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT TOP 1 * FROM [CIT_ContactInfo] ORDER BY NEWID()"
updatecommand="update [CIT_ContactInfo] set [Flag] = @.Flag where [UserName] = @.UserName">
<UpdateParameters>
<asp:Parameter Name="Flag" Type="boolean" />
</UpdateParameters>
</asp:SqlDataSource
Does any of this look remotely correct?
没有评论:
发表评论