stewie griffin 26 Light Poster

I have a conflict, using asp.net and c#.
Probably there is no big different between the two, what is faster?
Using function (with efficiency of n^2 - loop in loop) or taking data from small data base (simple query)