Need some quick help with C#


Registered Member
Jun 21, 2009
Reaction score
Ok, I am trying to retrieve a random record set from my OLEDB connected database.

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
 SELECT top 5 url FROM stories [code]

Only returns 5 stories, but there seems to be no way to change which 5 are returned.
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:
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.
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock