Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
i want to get the search result time like google when i'm using Datareader to fetch record from db
can anyone tell me how to do this?
Posted 2-Oct-12 4:21am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

for a very precise indication you can use the Stopwatch class
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch(v=vs.80).aspx[^]
var sw = new StopWatch();
sw.Start();
 
// Do your sql query

sw.Stop();
 
var timeSpent = sw.TotalMilliseconds;
 
  Permalink  
Comments
Surendra0x2 at 2-Oct-12 13:44pm
   
how to convert
var timeSpent = sw.ElapsedMilliseconds.ToString();
milliseconds to seconds i want to show result in seconds can u help me?
Surendra0x2 at 2-Oct-12 14:15pm
   
Thanks Buddy i got the solution :)
Guirec Le Bars at 2-Oct-12 22:27pm
   
I don't know who downvoted the solution to 1 but some explanations would probably make sense :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 295
1 OriginalGriff 285
2 Sergey Alexandrovich Kryukov 157
3 Afzaal Ahmad Zeeshan 154
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100