Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public List<int> Temperatura()
  2. {
  3. List<int> Datos = null;
  4. string connStr = "server=localhost;user=root;database=sensores;port=3306;password=123456;";
  5. MySqlConnection conn = new MySqlConnection(connStr);
  6. try
  7. {
  8. Console.WriteLine("Connecting to MySQL...");
  9. conn.Open();
  10.  
  11. string sql = "Select temperatura From datos where fecha between '" + Label3.Text + "' and '" + Label4.Text + "';";
  12. MySqlCommand cmd = new MySqlCommand(sql, conn);
  13. MySqlDataReader rdr = cmd.ExecuteReader();
  14.  
  15. while (rdr.Read())
  16. {
  17.  
  18. Datos.Add(Convert.ToInt32(rdr[0]));
  19. }
  20. rdr.Close();
  21. }
  22. catch (Exception ex)
  23. {
  24. Console.WriteLine(ex.ToString());
  25. }
  26.  
  27. conn.Close();
  28. Console.WriteLine("Done.");
  29. return Datos;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement