获取SQL Server服务器时间
由于用户可以修改计算机的系统时间,所以根据系统时间进行一些条件判断,不是很可靠,存在“作弊”的可能。
如果你采用SQL Server作为数据源,可以用下面的代码获得SQL Server服务器的时间:
Dim cmd As New SQLCommand
Dim dt As Date
cmd.ConnectionName = "数据源名称"
cmd.CommandText = "Select GetdDte()"
dt = cmd.ExecuteScalar()
如果只想获得时间的日期部分,代码为:
Dim cmd As New SQLCommand
Dim dt As Date
cmd.ConnectionName = "数据源名称"
cmd.CommandText = "Select GetdDte()"
dt = cmd.ExecuteScalar()
dt = dt.Date
错误提示为

此主题相关图片如下:qq截图20110708123833.png