C# Tutorial 15: How to Link Chart /Graph with Database




Creating graph in Windows Forms Application Mysql C# Data Binding a Chart to a Database C# Line chart in c# using data from database c# – Graph database …

Original source


27 responses to “C# Tutorial 15: How to Link Chart /Graph with Database”

  1. Instead of while loop with Reader, why not fill the Data with DataSet/DataTable
    & just assign it as datasource to chart
    chart1.Series.Add("age");
    chart1.Series["emp"].XValueMember = "name";
    chart1.Series["emp"].YValueMembers = "age";
    chart1.DataSource = data;
    chart1.DataBind();

  2. after finishing the coding as illustrated i got the message "the type or namespace charting does not exist in namespace System.Windows.Forms.DataVisualization"
    and when i tried to use Using System.Windows.Forms.DataVisualization.Charting again the same message appears there
    anyone please suggest me how to solve this problem and if  System.Windows.Forms.DataVisualization.Charting.dll can be added to the reference please provide the link to download it

  3.            
    it is connection to sql server 2008 and not by server explorer in visual studio 2008. 
    I hope it is useful for you.
    thank you for post.

                SqlConnection con1 = new SqlConnection();
                con1.ConnectionString = "Data Source=(local);Initial Catalog=DatabaseName;Integrated Security=true";
                con1.Open();
                SqlCommand cmd1 = new SqlCommand();
                cmd1.Connection = con1;
                cmd1.CommandText = "select ProductName,PriceProduct from Producttb";
                try
                {
                    SqlDataReader dr = cmd1.ExecuteReader();
                    
                    while (dr.Read())
                    {
                        chart3.Series["te1"].Points.AddXY(dr["ProductName"].ToString(), dr["PriceProduct"].ToString());

                        }
                    con1.Close();
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }

  4. Hello. I got an error on this line

    myReader.GetString("PRES_NAME"), myReader.GetInt32("PRES_VOTE")

    the whole line is underlined
    it says that "Argument 1: Cannot convert from string to int"

  5. Hi all,
    I am trying to get the chart axis title automatically from the data table columns but having problem. So far I can do it manually as follows: 
    this.chartTable.ChartAreas[0].AxisX.Title = "Age";
                this.chartTable.ChartAreas[0].AxisY.Title = "Name";

    Any help will be appriciated and tanks for the good work.

  6. hi, I am using Sql Database.
    i want to display the name of my database name column on the x axis on my graph,can u tell me how can i do it.
    and also want to fetch the data from a particular row at a time and display it on the graph.

  7. how to retrieve image from mysql in java asked the author of java prog#, I follow his tutorial how to insert image and retrieve, I can insert image in db but I can't retrieve, no erros, no reaction after click to the retrieve buton please help me

Leave a Reply