Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Dear Friends I want to show seconds in my asp.net web page that is occurring in fetching data from sql server please help me. for example in google when someone searches any term google will display something and displays seconds took in fetching data from server.
Posted

1 solution

In the code behind you could employ a Stopwatch which is part of System.Diagnostics;

Start the stopwatch immediately before the fetch begins, and stop it when complete. Then just look at the elapsed time for the operation.

See this link for the documentation on StopWatch system.diagnostics.stopwatch[^]
 
Share this answer
 
Comments
Satyendra Kumar(Analyst Programmer) 11-Jun-11 13:26pm    
watch.Start();
BindData();
watch.Stop();
TimeSpan ts = watch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
lbltime.Text = "RunTime " + elapsedTime;

Is this ok dear or not please tell me.
DaveAuld 11-Jun-11 13:28pm    
I don't know, try it and see! Basic theory looks fine :-)
Satyendra Kumar(Analyst Programmer) 11-Jun-11 13:32pm    
it is working but i am not sure that it is right one or not
DaveAuld 11-Jun-11 13:33pm    
What do you mean if its the right one or not?
Satyendra Kumar(Analyst Programmer) 11-Jun-11 13:41pm    
It is checking right fetching time or not BindData() is my function that is fetching Data from Database.

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