 |
|
 |
GeoffS Level: VB Lord

 Registered: 29-09-2004 Posts: 536
|
Re: Using getdate() from server
Hi Aeric,
Without knowing the precise nature of your company's setup and requirements it is impossible for me to say that the following is necessarily the best advice. But for what its worth here are my thoughts on your problem -
Last question first -
User Log-In Script.
When the user of a networked PC first logs on with the Windows Login screen his/her user name and password are checked by the Server computer for the Domain/Workgroup to which they belong. At this point the Server can run a user login script which, among other things, can set Network drives for the client PC and other environment variables. This file is saved as a Batch File (.bat) on the server. If you look on the shared folders of the server to which you connect you may possibly see a folder called "NetLogon" - you may find a sample script there, otherwise talk to the system administrator of your Network.
The point here is that adding the above line to a users network logon script will force the Client PC to synchronise time with the Server PC everytime a user logs in, which presumably will be at least once a day. Modern computers can keep acurate enough time over a 24 hour period so I would suggest that it would be perfectly safe to then use the local computers time for your needs. This not only saves processor time but also reduces the amount of traffic on the network - think how many users are sending time requests every second!! Also, unless your Server computer is connecting to a proper TimeServer on a regular basis who's to say that the time on that machine is exact?
So that, I think also answers Q1. By getting the time locally rather than over the Network the performance will improve anyway, but depending on how busy your Network is it could be quite a dramatic change.
Q2. Right - You answered yourself.
Q3. If accuracy of time compared to Server time is that important then yes, run a check occasionally, but once a second seems a bit much. No point using processor cycles to calculate time differences though, just apply the Server time directly to your local PC time (Time = ServerTime) But if you can live with the time being out by a few seconds then sychronisation by the login script has got to be the best way to go.
____________________________
multi-tasking - the ability to hang more than one app. at the same time.
|
|
07-10-2004 at 11:41 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Using getdate() from server
quote: Does this code affect the performance of the program since it executes every second to retrieve value from the server?
When I read about ADO while ago, I remember once some MS ADO Guru said that ADO recordset are very expensive to create so we need to avoid creating them whenever possible. In your code you create ADO recordset every second, so I think it surely does affect a performance, and especially in large network.
So, listen to Geoffs's advice and use Net Time command, and for your question how to use it, check this.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
07-10-2004 at 08:46 PM |
|
|
|
|
 |
 |