Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to create chart with data from my database by select product from checkbox in listbox and between date from datetimepicker bet when click the button for generate graph value in graph show same data for every series i don't know how to fix this problem

this is my code

C#
if (row.Cells[1].Value != null && (bool)row.Cells[1].FormattedValue)
                {                       
                        String idtoselect = row.Cells[0].Value.ToString();
                        String str1 = idtoselect.ToString();
                        
                        try
                        {
                            string sql2 = "select NAME_Product from Product where  Product.ID_Product = '"+str1+"' ";
                            SqlCommand testcommand2 = new SqlCommand(sql2, conn);
                            rdr = testcommand2.ExecuteReader();

                            while (rdr.Read())
                            {
                                test = rdr["NAME_Product"].ToString();

                            }
                            rdr.Close();

                            try
                            {
                                CultureInfo ci = new CultureInfo("th-TH");
                                string sql = "SELECT * FROM Order1 where ID_Product = '"+str1+"' AND DATE_Order BETWEEN '" + dateTimePicker1.Value.ToString("s") + "' AND '" + dateTimePicker2.Value.ToString("s") + "' ";
                                da = new SqlDataAdapter(sql, conn);
                                ds = new DataSet();
                                da.Fill(ds, "Order1");
                                chart1.DataSource = ds.Tables["Order1"];
                                chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
                                
                                chart1.Series.Add(test);
                                chart1.Series[test].ChartArea = "ChartArea1";
                                chart1.Series[test].BorderWidth = 4;
                                chart1.Series[test].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;                                
                                chart1.Series[test].YValueMembers += "QUANTITY_Order";
                                chart1.Series[test].XValueMember += "DATE_Order";

                                chart1.DataBind();
                                MessageBox.Show("test :" );
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("test :" + ex);
                            }
       
                        }
                        catch
                        {
                            MessageBox.Show("exception");
                        }


and this my output

http://image.ohozaa.com/view/80v2q]

i'm so sorry if i type a wrong word because my english is not good

Thank you for answer
Posted
Updated 28-Jan-12 20:58pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900