我正在使用 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 的结果放入系列中。如果您知道更好的解决方法,请告诉我。我即将开始一个项目,所以这将非常有帮助。
提前致谢