vb.net 同步服务器时间


     ''提示同步服务器时间。Modify By Liu Sg On 2010-07-06
                Dim sql As String = "select ServerDateTime=getdate() "
                Dim sServerDT As String = claOpt.ExecSqlScalar(sql)       '得到数据库服务器时间
                Dim sLocalDT As String = Now.ToString                            '得到本地时间
                If sServerDT.Trim <> sLocalDT.Trim Then                         '判断是否一样
                    If MsgBox("Local time and server time is not uniform," & Chr(13) & "It may make the system not work correctly," & Chr(13) & "Do you want unity as the server time[" & sServerDT & "]?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then               '提示是否更新时间.

                       ' '为了防止客人没有看到提示,或提示过长时间再点确定,造成同步时间不准确,这里再次新得到服务器时间.                       

                        'sServerDT = claOpt.ExecSqlScalar(sql)
                        'Today = CDate(sServerDT)
                        'TimeOfDay = CDate(sServerDT).TimeOfDay.ToString

                        Today = CDate(claOpt.ExecSqlScalar(sql))
                        TimeOfDay = CDate(claOpt.ExecSqlScalar(sql)).TimeOfDay.ToString
                    End If
                End If