我用在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