我用在C#工作的WinForms .NET4应用从SQL查询C#
我的目标是填充从一个特定的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的结果入编。 如果你知道更好的方法去做这个请让我知道。我即将开始一个项目,所以这将是非常有益的。
在此先感谢
你使用什么图表控件?它是微软吗? – 2012-07-24 11:03:42