Click here to Skip to main content
14,920,935 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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

1 solution

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[^]
C#
var sw = new StopWatch();
sw.Start();

// Do your sql query

sw.Stop();

var timeSpent = sw.TotalMilliseconds;
   
Comments
Surendra0x2 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 2-Oct-12 14:15pm
   
Thanks Buddy i got the solution :)
Guirec 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)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900