dim conn as new adodb.connection
Dim rs As New ADODB.Recordset
...            '此处建立你的连接 就是conn.open ....那个
rs.Open "Select getdate()", Conn '用这句语句就可以等到服务器的时间了
DT = rs.Fields(0).Value   '日期时间保存在DT中

解决方案 »

  1.   

    如果你的数据库是放在服务器上,即可通过联接到服务器的联接执行“select getdate()”从服务器上取得时间。
      

  2.   

    嘻嘻,分,我来了!
    '系统对时程序
    Public Function AdjustSystemTime(cn As ADODB.Connection) As Boolean
        Dim lastADOSQL As String
        Dim lastADORst As New ADODB.Recordset
        Dim serverTime As Date
        
        On Error GoTo Error_AdjustSystemTime
        
        lastADOSQL = "Select GETDATE()"
        lastADORst.Open  lastADOSQL,cn  
               serverTime = lastADORst.Fields(0).Value
           lastADORst.Close
        Else
           GoTo Error_AdjustSystemTime
        End If
        
        Date = Format(serverTime, "yyyy-mm-dd")
        Time = Format(serverTime, "hh:nn:ss")
        Set lastADORst = Nothing
        AdjustSystemTime = True
        Exit Function
        
    Error_AdjustSystemTime:
        Set lastADORst = Nothing
        AdjustSystemTime = False
    End Function
      

  3.   

    Else
           GoTo Error_AdjustSystemTime
        End If
     
        嘻嘻,上边的可以取掉,原来考虑如果不成功的话,作一个处理!
      

  4.   

    同意  davidwx(学习.提高.不吵架)