Inaam Hammouda

Inaam Hammouda

  • 1.8k
  • 42
  • 3.6k

real time chart and databse

May 8 2016 7:03 PM
hi beautiful people ,
i want to display real chart time , binded with Mysql databse .
Axe x shows the speed (int ) and Y shows DATETIME .
my databse get updated every second
 my load graph function is :
  1. public void load_graph()  
  2.        {  
  3.   
  4.            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("select * from val_api", conn);  
  5.            MySql.Data.MySqlClient.MySqlDataReader reader;  
  6.            try  
  7.            {  
  8.                conn.Open();  
  9.                reader = cmd.ExecuteReader();  
  10.                while (reader.Read())  
  11.                {  
  12.                    this.chart1.Series["Vitesse"].Points.AddXY(reader.GetInt16("vitesse"), reader.GetDateTime("dateV"));  
  13.                    this.chart1.Update();  
  14.            
  15.   
  16.                }  
  17.            }  
  18.            catch (Exception ex)  
  19.            {  
  20.                MessageBox.Show(this, ex.Message);  
  21.            }  
  22.            conn.Close();  
  23.        }  
 i tried using this fuction with timer , but it doesn't work , a line shows up and than my app stops without throwing any exception .
can you please help  
 

Answers (1)