原創(chuàng)|其它|編輯:郝浩|2012-10-15 16:04:45.000|閱讀 835 次
概述:主要以代碼說明,讀取SQL server數(shù)據(jù)之后,并通過控件teechart顯示出數(shù)據(jù)曲線
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在讀取了SQL Server數(shù)據(jù)之后,并通過控件Teechart顯示出數(shù)據(jù)曲線,在這里貼出這種方式的源碼,大家一起探討一下:
源碼如下:
using System; using System.Drawing; using System.Windows.Forms; using System.Data.SqlClient; using System.Diagnostics; namespace tchart_SQL { public partial class Form1 : Form { private string connString = @"server = localhost;integrated security = true; database = student"; string s = "select studentID,[英語],[數(shù)學(xué)],[語文],[總分] from score order by studentID Desc";//[英語],[數(shù)學(xué)],[語文],[總分] public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Stopwatch sw = new Stopwatch();//測試性能 sw.Start(); tChart1.Aspect.View3D = false; SqlConnection conn = new SqlConnection(connString); conn.Open(); SqlCommand cmd2 = new SqlCommand(s, conn); SqlDataReader aReader = cmd2.ExecuteReader(); line1.Title = "英語"; line2.Title = "數(shù)學(xué)"; line3.Title = "語文"; line4.Title = "總分"; while (aReader.Read()) { line1.Add(Convert.ToInt32(aReader[1]),aReader[0].ToString(),Color.Red); line2.Add(Convert.ToInt32(aReader[2]),aReader[0].ToString(),Color.Black); line3.Add(Convert.ToInt32(aReader[3]),aReader[0].ToString(),Color.Blue); line4.Add(Convert.ToInt32(aReader[4]),aReader[0].ToString(),Color.DarkRed); } aReader.Close(); conn.Close(); sw.Stop(); MessageBox.Show(sw.ElapsedMilliseconds.ToString()); } } }<DIV> <IMG alt="" src="//hi.csdn.net/attachment/201108/4/0_1312421740B1HB.gif"></DIV>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:CSDN