Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }