Updating The System Clock?

  • Thread starter Thread starter Mario T. Lanza
  • Start date Start date
M

Mario T. Lanza

Greetings,

I am developing an app that utilizes a custom internet-based
replication process. Every record in my database has a DateAdded and
DateUpdated column to facilitate this. There are many satellite
locations and one master home office location whose database is
considered the master database.

I haven't run into any major issues yet. To further guarantee that I
will not, I want to have all satellites periodically via a web service
request the home office location's clock time.

Getting the home office clock time is easy -- I'll just use
DateTime.Now.

Once a satellite location acquires this info I need to update the
satellite machine's clock time. What is the .NET command for doing
this? I suspect the difficult of my finding this command deals with a
security issue...

Mario T. Lanza
Clarity Information Architecture, Inc.
 
Hi Mario,

If you are using VB.NET, the Visual Basic Today function is
actually a Property which can be set - affecting the system date.
Similarly TimeOfDay will set the system clock.

I don't know what the Framework equivalent is, so if you're
using C# then you'd have to import Microsoft.VisualBasic.

Regards,
Fergus
 
If you are using VB.NET, the Visual Basic Today function is
actually a Property which can be set - affecting the system date.
Similarly TimeOfDay will set the system clock.

I don't know what the Framework equivalent is, so if you're
using C# then you'd have to import Microsoft.VisualBasic.

Regards,
Fergus

Public Module Module1
Sub SetTimeOfDay(ByVal Time As String)
Dim NewTime As String = Date.Today.ToShortDateString() + " " + Time
Dim NewDate = Date.Parse(NewTime)
Today = NewDate
End Sub
End Module

From within my C# project I called the VB module...

Module1.SetTimeOfDay("10:50pm")

This did not work.

!?
Mario
 
Hi Mario,

|| If you are using VB.NET, the Visual Basic Today function is
|| actually a Property which can be set - affecting the system date.
|| Similarly <TimeOfDay> will set the system clock.

Your routine was setting the system date (Today) rather than the system clock
(TimeOfDay).

You've got a choice of two methods.

1) In your C# project add the following:
A reference to MS Visual Basic .NET Runtime.

a)
Microsoft.VisualBasic.DateAndTime.TimeOfDay
= DateTime.Parse (sSomeTimeString);

b)
using VB = Microsoft.VisualBasic;

VB.DateAndTime.TimeOfDay = DateTime.Parse (sSomeTimeString);

2) In your VB project use

Public Module Module1
Sub SetTimeOfDay(ByVal NewTime As String)
TimeOfDay = DateTime.Parse(NewTime)
End Sub
End Module

Regards,
Fergus
 
Back
Top