如果在C#程序中获取远程服务器的系统日期和时间(C/S架构下) 如题,我的远程服务器数据库采用的是SQL SERVER 2005。该如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #region 获取服务器时间 public static DateTime GetServerTime() { SqlConnection con = GetConn(); SqlCommand com = new SqlCommand("select getdate()", con); con.Open(); DateTime time = (DateTime)com.ExecuteScalar(); con.Close(); return time; } public static string GetServerTimeStr() { SqlConnection con = GetConn(); SqlCommand com = new SqlCommand("select getdate()", con); con.Open(); DateTime time = (DateTime)com.ExecuteScalar(); con.Close(); return time.ToString("yyyyMMddhhmmssff"); } #endregion C#中进程的暂停和继续 C#制作英文安装包的问题 C#窗体和控件背景图片问题 c# DragDrop 注册失败 请问如何用session的方式取得用户离开网站的时间? 初学者问题。 不知道为什么发的帖子总没有人理,希望大家帮帮忙吧! 关于类指针的问题 邀请wangjiong(wj)和Web Service高手进来 求教,关于多线程的设计问题!!! 请教,C# winform 里怎么实现用户登录 搜狗那个的皮肤控件时如何做出来的,能被调用吗
public static DateTime GetServerTime()
{
SqlConnection con = GetConn();
SqlCommand com = new SqlCommand("select getdate()", con);
con.Open();
DateTime time = (DateTime)com.ExecuteScalar();
con.Close();
return time;
} public static string GetServerTimeStr()
{
SqlConnection con = GetConn();
SqlCommand com = new SqlCommand("select getdate()", con);
con.Open();
DateTime time = (DateTime)com.ExecuteScalar();
con.Close();
return time.ToString("yyyyMMddhhmmssff");
}
#endregion