【发布时间】:2017-05-20 23:49:45
【问题描述】:
大家好,我需要一些帮助才能在 Windows 窗体应用程序中绘制图形。
我从这里下载了 .NET Community Edition 的 Nevron Chart:
https://www.nevron.com/products-dot-net-chart-free-control
然后我从 Windows 窗体应用程序的工具中拖出一张图表
所以我在图表中与 MySql 建立连接,但我需要在图表中导出查询。
我的代码是:
private void chart1_Click(object sender, EventArgs e) {
string MyConString3 = "SERVER=localhost;" + "DATABASE=hydrodb;" +
"UID=root;" + "PASSWORD=;";
MySqlConnection connection3 = new MySqlConnection(MyConString3);
string command3 = "select year(Dat),month(Dat),min(vkolmin),avg(Vkolsre),Max(Vkolmax) from hydmes where station='"
+ comboBox1.SelectedItem.ToString() + "' and Dat between '"
+ comboBox2.SelectedItem.ToString() + "' and '" + comboBox3.SelectedItem.ToString()
+ "' group by year(dat),month(Dat)";
MySqlDataAdapter da3 = new MySqlDataAdapter(command3, connection3);
DataTable dt3 = new DataTable();
da3.Fill(dt3);
string s = "";
foreach (DataRow row in dt3.Rows) {
string rowz = string.Format("{0}, {1}, {2}, {3}, {4}", row.ItemArray[0], row.ItemArray[1], row.ItemArray[2],
row.ItemArray[3], row.ItemArray[4]);
s += "-" + rowz;
}
connection3.Close();
}
我不确定我是否需要 foreach ?
我需要从
导出这个查询string command3 = "select year(Dat),month(Dat),min(vkolmin),avg(Vkolsre),Max(Vkolmax) from hydmes where station='"
+ comboBox1.SelectedItem.ToString() + "' and Dat between '"
+ comboBox2.SelectedItem.ToString() + "' and '" + comboBox3.SelectedItem.ToString()
+ "' group by year(dat),month(Dat)";`
在图表中?
一些关于代码的帮助?
【问题讨论】:
-
这个不清楚,你对
dt3中的行做了什么?您需要在图表中导出查询,只是图表图形或SQL?你在哪里分配图表数据源? -
你能给我示例代码吗?
-
这是我的数据库字符串,字符串 MyConString3 = "SERVER=localhost;" +“数据库=hydrodb;” + "UID=root;" + "密码=;";
-
你的标题似乎很误导人。您正在寻找的只是将查询中的数据提供给 Nevron Chart,对吗?请更正标题和标签!
-
大声笑老兄,我问了你 3 件事来澄清你的问题,你没有回答任何问题并回复 请给我 teh codez!