|
|
|
start date: Tue, 21 Aug 2007 09:34:07 -0000,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
dungdang
|
|
2
unknown
|
|
3
dungdang
|
|
4
DC
|
Select a Random Number from MSAccess Table Using C#
Hello,
I want to use C# to select a random number from MS Access database
table.
<SELECT TOP 1 userID FROM users ORDER BY NEWID()> seem to work only
with SQL Server.
dungdang
Date:Tue, 21 Aug 2007 09:34:07 -0000
Author:
|
Re: Select a Random Number from MSAccess Table Using C#
You may be better off asking directly in an Access group, however, you
could do this directly in your Access query by using the RND function
in conjunction with a calculation on a field e.g.
SELECT TOP 1 Rnd(Len([LastName])) AS Expr1, LastName
FROM Employees
ORDER BY Rnd(Len([LastName])) DESC;
Date:Tue, 21 Aug 2007 02:48:23 -0700
Author:
|
Re: Select a Random Number from MSAccess Table Using C#
the On Aug 21, 9:48 am, "ca8...@aspnetlibrary.com"
wrote:
> You may be better off asking directly in an Access group, however, you
> could do this directly in your Access query by using the RND function
> in conjunction with a calculation on a field e.g.
>
> SELECT TOP 1 Rnd(Len([LastName])) AS Expr1, LastName
> FROM Employees
> ORDER BY Rnd(Len([LastName])) DESC;
I've this method also, on the Access it works fine..but on C# code
(WinForm), it keeps constatntly picking the same number again and
again..
Date:Tue, 21 Aug 2007 13:01:26 -0000
Author:
|
Re: Select a Random Number from MSAccess Table Using C#
dungdang wrote:
> Hello,
> I want to use C# to select a random number from MS Access database
> table.
> <SELECT TOP 1 userID FROM users ORDER BY NEWID()> seem to work only
> with SQL Server.
>
> dungdang
>
Do you use the "randomise" function befor using RND? if not then you
will always get the same "random" number as you are not getting the
clock to seed the RND function.
Luck,
Date:Wed, 22 Aug 2007 12:07:23 +0100
Author:
|
|
|