$pro= ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$pro.Open ("driver={SQL Server};server=192.168.0.251;uid=test;pwd=test;database=test")
$RS.ActiveConnection = $pro
$sql='select top 1 dtTime1 FROM tLogs ORDER BY dtTime2 DESC '
$RS.Open($sql)
While (Not $RS.eof And Not $RS.bof)
$a=$RS.Fields (0).value
$y=StringMid($a,1,4)
$m=StringMid($a,5,2)
$d=StringMid($a,7,2)
$t1=StringMid($a,9,2)
$t2=StringMid($a,11,2)
$t3=StringMid($a,13,2)
MsgBox(0,"",$y & '/' &$m & '/' & $d & ' ' & $t1 & ':' & $t2 & ':' & $t3)
MsgBox(0,"",$a)
$RS.movenext
WEnd
$RS.close
$pro.close
看看对你有无帮助 |