Hi,

can anyone guide me on how to check the server DateTime when the application launch. i want to make sure the user PC has the same DateTime as server when the user use the application. Reason being is some user may tend to change their DateTime backward and it causes a major confusion when it update in the server database.
Please guide me !

Recommended Answers

All 5 Replies

does any1 know abt this....

HELP !!!!!!!!!!!!!!!

hi,

can any1 help me on the problem am facing now..Please help!

can any1 help me to solve this....please help...i need it urgently....as i couldn't find any solution till now....HELP PLEASE

HI ,
below is my code..please help me to solve this

Public Sub GetServerDateTime()
        Dim WMIScope As Management.ManagementScope
        Dim WMIConnectionOptions As New Management.ConnectionOptions
        Dim oq As New System.Management.ObjectQuery
        Dim query As ManagementObjectSearcher
        Dim queryCollection As ManagementObjectCollection
        Dim Strcomputer As String = "999.999.999.99"

        With WMIConnectionOptions
            .Impersonation = System.Management.ImpersonationLevel.Impersonate
            .Authentication = System.Management.AuthenticationLevel.Packet
        End With

        WMIScope = New Management.ManagementScope("\\" & _
                    Strcomputer & "\root\cimv2", WMIConnectionOptions)

        oq = New System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem")
        query = New ManagementObjectSearcher(WMIScope, oq)
        queryCollection = query.Get()

        For Each oReturn As ManagementObject In queryCollection
            Debug.Print(oReturn("LocalDateTime").ToString())
        Next

        'Dim objWMI As New ManagementObjectSearcher _
        '              ("SELECT * FROM Win32_OperatingSystem ")
        'Dim objProcess As ManagementObject


        'For Each objProcess In objWMI.Get
        '    If objProcess("Caption").ToString = "RBMKiosk.exe" Then
        '        bolExist = True
        '    End If
        'Next
    End Sub
Public Function GetServerDateTime() As DateTime
        Dim myConnection As SqlConnection
        Dim myCommand As SqlCommand
        Dim strSQL As String = ""
        Dim icount As Integer

        myConnection = GetConnectCRLimit("REMOTE")
        myConnection.Open()


        CurrentTranxDateTime = Now
        CurrentTranxDate = System.DateTime.Now.ToString("dd-MMM-yyyy")
        CurrentTranxTime = System.DateTime.Now.ToString("hh:mm:ss tt")


        GetServerDateTime()
        strSQL = "INSERT INTO dbo.ServerDateTime([DateTime]) VALUES ('" & GetServerDateTime() & "')"

        myCommand = New SqlCommand(strSQL, myConnection)
        icount = myCommand.ExecuteNonQuery()

        myConnection.Close()
    End Function

Hi,

can anyone guide me on how to check the server DateTime when the application launch. i want to make sure the user PC has the same DateTime as server when the user use the application. Reason being is some user may tend to change their DateTime backward and it causes a major confusion when it update in the server database.
Please guide me !

Hi,

I'm not sure about how to help you, but you can find some explanation about serverdatetimes, here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.