public static void checkCompany(string username) { SqlConnection connection = DBO.CreateConn(); SqlDataAdapter adapter = new SqlDataAdapter("select usertype,end_time from company where username='******'", connection); DataSet ds = new DataSet(); adapter.Fill(ds); string strType = ds.Tables[0].Rows[0]["usertype"].ToString(); string strSpan = ds.Tables[0].Rows[0]["end_time"].ToString(); if (strType == "0") { DBO.UserRole(username, "c_test"); } else { DateTime now = DateTime.Now; TimeSpan span = (TimeSpan)(DateTime.Parse(strSpan) - now); if (span.Hours > 0) { DBO.UserRole(username, "c_normal"); } else { DBO.UserRole(username, "c_end"); } } }