Advertisement
HenX

Untitled

Dec 20th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1.   protected void RefreshTimer_Tick(object sender, EventArgs e)
  2.         {
  3.             List<String> dates = new List<String>();
  4.             SqlConnection conn = new SqlConnection();
  5.             conn.ConnectionString = "Data Source=80.82.149.94;Initial Catalog=udbstest;Persist Security Info=True;User ID=udbstest;Password=pass1234;Connection Timeout=5;";
  6.             conn.Open();
  7.             SqlCommand command = new SqlCommand("SELECT GETDATE() AS CurrentDateTime", conn);
  8.             using (SqlDataReader reader = command.ExecuteReader())
  9.             {
  10.                 while (reader.Read())
  11.                 {
  12.                     dates.Add(reader.GetDateTime(0).ToString());
  13.                 }
  14.             }
  15.             conn.Close();
  16.  
  17.             testgrid.DataSource = dates;
  18.             testgrid.DataBind();
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement