public static string GetServerTimeString() { StringBuilder strSql = new StringBuilder(); strSql.Append("select GetDate() as serverdate "); Sqlconn theTestDb = new Sqlconn(); DataSet theDs = theTestDb.Query(strSql.ToString()); return(theDs != null ? theDs.Tables[0].Rows[0][0].ToString() : null); }
public static DateTime GetServerTime() { StringBuilder strSql = new StringBuilder(); strSql.Append("select GetDate() as serverdate "); Sqlconn theTestDb = new Sqlconn(); DataSet theDs = theTestDb.Query(strSql.ToString()); if (theDs != null && theDs.Tables.Count != 0) { return(DateTime.Parse(theDs.Tables[0].Rows[0][0].ToString())); } else { return(DateTime.Now); } }