Need some quick help with C#

SHOwnsYou

Registered Member
Joined
Jun 21, 2009
Messages
97
Reaction score
99
[FONT=&quot]
Ok, I am trying to retrieve a random record set from my OLEDB connected database.

Code:
OleDbDataAdapter adapter2 = new OleDbDataAdapter("Select top 5 url from stories ORDER BY rnd()", aConn);

I tried this, but it returns the entire record set.

Just using the sql
Code:
 SELECT top 5 url FROM stories [code]

Only returns 5 stories, but there seems to be no way to change which 5 are returned.
[/FONT]
 
Selecting random in TSQL is not the best place to have such logic. But if you really must do that here is an article that will teach you more:

http://www.kodyaz.com/articles/top-n-random-rows-foreach-category-or-group.aspx
 
Thanks for the quick reply!

I figured using oledb wasnt the best way to approach this, but I am more itnerested in giving this another test run.

I do plan to rewrite it and make it more efficient, but right now I don't have the time.
 
Back
Top