vb获取服务器时间
在窗体中建一个文本框和时间控件,可以在文本框中显示跳动的服务器时间
Private Sub Form_Load()
Timer1Interval = 300
End Sub
Private Sub Timer1_Timer()
Dim cnn As New ADODBConnection
Dim cmd As New ADODBCommand
Dim rst As New ADODBRecordset
Dim Sqlser_time
cnnConnectionString = "driver={SQL Server};" & _
"server=server;uid=sa;pwd=;database=master"
cnnOpen
cmdActiveConnection = cnn
cmdCommandText = "SELECT GETDATE() AS sys_Sqlser_time"
Set rst = cmdExecute
Sqlser_time = rst(0)
Text1Text = Sqlser_time
rstClose
cnnClose
End Sub
0条评论