vb.net 同步服务器时间

                'claOpt是我自定义的一个数据库连接读取类

     ''提示同步服务器时间。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

                        '[这样还是有误差,再次完善修改于2010-07-22]
                        Today = CDate(claOpt.ExecSqlScalar(sql))
                        TimeOfDay = CDate(claOpt.ExecSqlScalar(sql)).TimeOfDay.ToString
                    End If
                End If

没有更多推荐了,返回首页