【发布时间】:2012-07-24 11:02:01
【问题描述】:
我正在使用 C# winforms .NET4 应用程序
我的目标是从特定的 SQL 查询填充图表控件。
“选择人的身高”
简单的查询,但我不确定将查询结果放入图表控件的最佳方法。
这是我目前所拥有的:
private void button1_Click(object sender, EventArgs e)
{
SqlConnection mainconnection = new SqlConnection("Data Source=commandhq;Initial Catalog=projecttest;Integrated Security=True");
mainconnection.Open();
string query = "SELECT height from persons";
SqlCommand querycommand = new SqlCommand(query, mainconnection);
SqlDataReader querycommandreader = querycommand.ExecuteReader();
Series thesqlresultsplease = new Series();
//Populate series with results from the sql query
chart1.Series[0].XValueMember = thesqlresultsplease.XValueMember; //will this work?
}
我的问题是:
如何将 sqldatareader 的结果放入系列中。 如果您知道更好的解决方法,请告诉我。我即将开始一个项目,所以这将非常有帮助。
提前致谢
【问题讨论】:
-
您使用什么图表控件?是微软吗?