MSChart视图问题 [英] MSChart view problem

查看:108
本文介绍了MSChart视图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在mschart上显示数据,但是sql连接没有问题.仅显示图表标题.有什么建议吗?

I can''t show the data on mschart but there is no problem with sql connection. only the title of the chart is appearing. Any Suggestions?

SqlConnection connection = new SqlConnection("Data Source=ccsmsmq01;Initial Catalog=DivaReportTest;User ID=DivaReportDev;Password=****");
       SqlDataAdapter adapter;
       protected void Page_Load(object sender, EventArgs e)
       {
           if (!Page.IsPostBack)
           {
               VerileriGetir();
           }
       }

       private void VerileriGetir()
       {
           string selectSQL = " SELECT Period, Total FROM IVR_PROFILE_CALL_PEAKS";

           adapter = new SqlDataAdapter(selectSQL, connection);

           DataTable table = new DataTable();
           adapter.Fill(table);

           DataSet ds = new DataSet();
           adapter.Fill(ds,"Chart1");


           Chart1.DataSource = adapter ;
           Chart1.DataBind();
           Chart1.Titles.Add("Department Wise Employee Count");
           Chart1.Series["Series1"].XValueMember = "Period";
           Chart1.Series["Series1"].YValueMembers = "Total";

       }


<asp:Chart ID="Chart1" runat="server" >
            <series>
                <asp:Series Name="Series1">
                
            </series>
            <chartareas>
                <asp:ChartArea Name="ChartArea1">
                
            </chartareas>

推荐答案

您不能直接将适配器添加为数据源.在数据源中,您需要提及该表.因此,请尝试以下操作,

You cannot directly add an adapter as datasource. In datasource you need to mention the table. So try the following,

DataSet ds = new DataSet();
adapter.Fill(ds);
Chart1.DataSource = ds[table_name];



用上面的代码替换代码的以下部分:



Replace the following portion of the code with the above code:

DataTable table = new DataTable();
adapter.Fill(table);

DataSet ds = new DataSet();
adapter.Fill(ds,"Chart1");

 
Chart1.DataSource = adapter ;


这篇关于MSChart视图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆