|
-
Apr 30th, 2001, 10:52 AM
#1
Thread Starter
Hyperactive Member
Date from Server, Not System
Hi!
Does anyone have an API function or some other code, that instead of getting the date of the system that is asking for it in my app, to get the date of the server where the data is held (i.e. my SQL server)?
Any suggestions/comments would be greatly appreciated.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Apr 30th, 2001, 01:35 PM
#2
New Member
using winsock?
This may be a bit of a lame idea, but what about making the server broadcast the time every 10 seconds or so?
Man who walks through airport turnstiles sideways is going to Bangkok
-
Apr 30th, 2001, 01:39 PM
#3
Thread Starter
Hyperactive Member
Hmm...
Thanks for your reply.
How do I do that(what would broadcasting it do?)? Any sample code would be appreciated. Also, would I be able to save that date in a database table?
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Apr 30th, 2001, 01:58 PM
#4
New Member
winsock
If you have your server running this line of code every 10 seconds:
Code:
winsock1.protocol = UDPprotocol or whatever it is, I can't remember what it is but there are only two options, pick the UDPish one
winsock1.remotehost "255.255.255.255"
winsock1.senddata time$
and, on your client, under winsock1_dataarrival event:
Code:
winsock1.getdata timein, vbstring
and then the time, which is updated every 10 seconds, is stored in the variable timein, so that should give you a 10 second accuracy of the time. If you want you can increment the timein every 10 seconds so that you have the time to an accuracy of 1 second from the server.
Let me know what you think!
Man who walks through airport turnstiles sideways is going to Bangkok
-
Apr 30th, 2001, 02:02 PM
#5
Thread Starter
Hyperactive Member
What about the date?
Is this the same for the date? That is what I am really looking for. Also, is there a need for me to add a specific component/reference, if so, what is it?
Thanks again for all your help.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
May 1st, 2001, 01:46 AM
#6
Addicted Member
IDEA
Why dont u try passing a SQL query to ur SQL server to retrieve the Date/Time from the server. There might be a discrepency of 1 or 2 secs. but u can get the date and time.
try using the select statement
select sysdate from dual; ( This code is for ORACLE i really dont remember what it will be for SQL server)
But i think this should work.
Let me know ur views about this
-
May 1st, 2001, 07:20 AM
#7
Thread Starter
Hyperactive Member
Thanks!
Thanks clipsie and pavan,
I will try both of your suggestions. Thanks again.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
May 1st, 2001, 09:35 AM
#8
Member
For SQL server, I believe the command would be:
"SELECT now() AS ServerDateTime FROM <InsertSomeTableNameHere> LIMIT 1"
I think you have to specify a valid table though. And the AS is a vague recollection... there's a command like that, anyway.
Sorry I can't be of more specific assistance.
Matthew Draper
[email protected]
"Genius may have its limitations, but stupidity is not thus handicapped." - Elbert Hubbard
"I like long walks, especially when they are taken by people who annoy me." - Noel Coward
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|