<script runat="server">
Public objConn as new OleDbConnection (System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))
Sub GetTeam(s as Object, E as EventArgs)
Dim objCmd As New OleDbCommand("SELECT TOP 4 PlayerID FROM tblPlayers WHERE PositionID='defender' ORDER BY rnd(isnull(PlayerID)*0+1);", objConn)
Try
objConn.Open()
dgDef.DataSource = objCmd.ExecuteReader
dgDef.DataBind()
objConn.Close()
Catch ex as OleDbException
throw ex
End try
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<form runat="server">
<p>
<asp:Button ID="btn33" runat="server" OnClick="GetTeam" Text="Get Defenders" />
</p>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr>
<td></td>
Defenders
<aspataGrid runat="server" ID="dgDef" EnableViewState="false" />
</tr>
</table>
<p> </p>
</form>
</body>
</html>
I have also tried:
SELECT TOP 4 PlayerID FROM tblPlayers WHERE PositionID='defender' ORDER BY newid()
But this doesn't work in Access or from my ASP.Net page and returns the error:
Undefined function 'newid' in expression
I believe that I need to force access to use a different seed each time it uses the rnd() function.
Could anyone help with doing this using ASP.Net. In ASP there was RANDOMIZE. I think the alternative in .Net is Random().
There is some history to this story here: (sorry if anyone classes this as a double post but this is more about using .Net to force a new seed for each query)
Any help would be greatly appreciated.
Many thanks
Shaun
Public objConn as new OleDbConnection (System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))
Sub GetTeam(s as Object, E as EventArgs)
Dim objCmd As New OleDbCommand("SELECT TOP 4 PlayerID FROM tblPlayers WHERE PositionID='defender' ORDER BY rnd(isnull(PlayerID)*0+1);", objConn)
Try
objConn.Open()
dgDef.DataSource = objCmd.ExecuteReader
dgDef.DataBind()
objConn.Close()
Catch ex as OleDbException
throw ex
End try
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<form runat="server">
<p>
<asp:Button ID="btn33" runat="server" OnClick="GetTeam" Text="Get Defenders" />
</p>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr>
<td></td>
Defenders
<aspataGrid runat="server" ID="dgDef" EnableViewState="false" />
</tr>
</table>
<p> </p>
</form>
</body>
</html>
I have also tried:
SELECT TOP 4 PlayerID FROM tblPlayers WHERE PositionID='defender' ORDER BY newid()
But this doesn't work in Access or from my ASP.Net page and returns the error:
Undefined function 'newid' in expression
I believe that I need to force access to use a different seed each time it uses the rnd() function.
Could anyone help with doing this using ASP.Net. In ASP there was RANDOMIZE. I think the alternative in .Net is Random().
There is some history to this story here: (sorry if anyone classes this as a double post but this is more about using .Net to force a new seed for each query)
Any help would be greatly appreciated.
Many thanks
Shaun