Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unable to get random generation with OleDb
Message
From
17/09/2006 18:29:51
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
17/09/2006 18:17:55
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01154512
Message ID:
01154514
Views:
9
While I have no experience with OleDb, in Visual FoxPro you need to initialize the random number sequence, with a negative seed. For example:
rand(-1) && Initialize random sequence, based on system time
for i = 1 to 100
  ? rand()
next
Omiting the first step will always produce the same sequence (if you restart Visual FoxPro in between, or convert it to an executable).

I don't know what would be the best way to invoke this in your situation.

>When using OleDb, from VB.NET, to get data from Visual FoxPro, I cannot get the random generation to work. Basically, if I execute this line from VFP, I will get the expected result. This means at every SQL result, I get a random record sequence order.
>
>
>SELECT TOP 10 RAND(),Video.Date,Video.Numero,Video.Title,Video.NoVideoT,Video.Notes_E,Video.Notes_F,Master.FirstName,;
> Master.LastName,Program.Title AS Program,Video.NoProgram,Video.NoClass,Video.Url;
> FROM Video;
> INNER JOIN Master ON Video.NoMaster=Master.Numero;
> LEFT JOIN Program ON Video.NoProgram=Program.Numero;
> WHERE Video.Date<=DATE() AND Video.Active;
> ORDER BY 1 DESC
>
>
>But, if this line is called from VB.NET by the use of the OleDb, I will always get 0.91 for the RAND() value. Is there a way to make that work in that environment?
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform