Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 数据未显示在图表中..仅显示空白C_C#_Winforms_Charts - Fatal编程技术网

C# 数据未显示在图表中..仅显示空白C

C# 数据未显示在图表中..仅显示空白C,c#,winforms,charts,C#,Winforms,Charts,大家好,我想把数据库中的数据用图表表示出来。 但是它什么也不显示,也没有错误,当跟踪使用断点时,它工作正常 是这样做的,还是有其他方法来做,因为我需要把它放在一个列表中,这样来自数据库的数据将被解密,因为它是加密的 SqlCommand comm = new SqlCommand("select s.ProductID, p.ProductDesc, YEAR(SalesDate)as year, ISNULL(sum(s.Qty), 0.0) as total from Sales

大家好,我想把数据库中的数据用图表表示出来。 但是它什么也不显示,也没有错误,当跟踪使用断点时,它工作正常

是这样做的,还是有其他方法来做,因为我需要把它放在一个列表中,这样来自数据库的数据将被解密,因为它是加密的

SqlCommand comm = new SqlCommand("select s.ProductID, p.ProductDesc, YEAR(SalesDate)as year, ISNULL(sum(s.Qty), 0.0) as total from Sales as s inner join Products as p on p.ProductID = s.ProductID WHERE Status = 'Sold' GROUP BY YEAR(SalesDate),s.ProductID, p.ProductDesc ", sqlconn);
        SqlDataReader dr = comm.ExecuteReader();
        List<string> list = new List<string>();
        List<int> total = new List<int>();
        while(dr.Read())
        {
            list.Add(Cryptor.Decode(dr["ProductDesc"].ToString()));
            total.Add(int.Parse(dr["total"].ToString()));
            
        }
        Series s1 = chartSales.Series["Series1"];
        s1.ChartType = SeriesChartType.Doughnut;
        s1.Name = "Sales";
        
        
        
        foreach (string i in list)
        {
            chartSales.Series["Sales"].XValueMember = i;
        }
        foreach(int i in total)
        {
            chartSales.Series["Sales"].YValueMembers = i.ToString();
        }

请给我拿一杯冷饮好吗?目前您还不清楚问题是与SQL查询有关还是与图表有关,因此最好将问题缩小到一个或另一个,然后再询问。@Llama查询中没有问题,我只需要在添加到图表之前解密ProductDesc列,也就是说,我解密它并将其添加到列表中,然后我建议删除问题中的SQL和解密组件,只需创建一个列表和带有硬编码值的列表总数。因为查询或解码没有问题?解密?不一样的事。。。数据,你需要的只是数值和图表代码,对吗?