Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2008-05-26 19:26:42

elbekko
Former Developer
From: Leuven, Belgium
Registered: 2008-04-30
Posts: 1,131
Website

I need help with Access

Let me just start with: Access sucks arse, and so does VB.

Now then, to the problem. I have to get a random row from a table in VB using an Access database. When testing out this simple query in Access (by using the query editor and pressing run), it works fine:

SELECT TOP 1 *
FROM woorden
WHERE woordid NOT IN( 0, 2, 58 )
ORDER BY RND(woordid);

But when I execute it from VB, it always returns the same resultset for some reason.
I tried creating a stored query, and sending whatever is in the IN as a parameter to it, but it still doesn't get a proper new resultset.

I have no idea wtf its problem is, but I'd like a solution that doesn't involve me recreating the whole program (I have to hand it in on thursday).

Any help would be appreciated, since this idiocy is really pissing me off.


Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Offline

#2 2008-05-27 10:54:07

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,135
Website

Re: I need help with Access

http://www.techonthenet.com/access/func … ic/rnd.php
I think RND works like RAND in MySQL, in that by passing a parameter you're always seeding the random number generator in the same way.

Offline

#3 2008-05-27 10:56:51

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,135
Website

Offline

#4 2008-05-27 15:07:54

elbekko
Former Developer
From: Leuven, Belgium
Registered: 2008-04-30
Posts: 1,131
Website

Re: I need help with Access

None of those seem to work. And I think I know why.
Access seems to interpret it all a bit differently than say MySQL. Whatever comes after ORDER BY solely specifies which column to order by and not to order randomly.

I still wonder why it works when you directly execute it in Access, but not in VB.


Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Offline

Board footer

Powered by FluxBB 1.5.0