如何将zedgraph图表与mysql数据库连接 [英] how to connect zedgraph chart with mysql database

查看:81
本文介绍了如何将zedgraph图表与mysql数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好所有成员

我在将ZedGraph图表与mysql数据库链接时遇到问题
请,如果有人有一个主意,请帮助我.

hello all members

I''ve got problem with linking ZedGraph chart with linking to mysql database
please if somebody have got an idea, please help me.

             private void Form1_Resize( object sender, EventArgs e )
		{
			SetSize();
		}
		private void SetSize()
		{
		zedGraphControl1.Location = new Point( 10, 10 );
	        zedGraphControl1.Size = new Size( ClientRectangle.Width - 20,	                                 ClientRectangle.Height - 20 );
		}
		// Respond to form 'Load' event
		private void Form1_Load( object sender, EventArgs e )
		{			
			CreateGraph( zedGraphControl1 );
			SetSize();
		}
		// Build the Chart
		private void CreateGraph( ZedGraphControl zgc )
		{
			GraphPane myPane = zgc.GraphPane;
			int iNbProduits = 0;
			//Détermination du nombre de produits
			_bd.Command.CommandText = "SELECT COUNT(*) " +
				"FROM Client";
			_bd.Reader = _bd.Command.ExecuteReader();
			if (_bd.Reader.Read()) {
				iNbProduits = int.Parse(_bd.Reader[0].ToString());
			}
			_bd.Reader.Close();
			string[] labels = new string[iNbProduits];
	          	PointPairList list1 = new PointPairList();
//		        double[] y = new double[iNbProduits];
			_bd.Command.CommandText = "SELECT `Nom`, `solde`" +
				"FROM Client";
			_bd.Reader = _bd.Command.ExecuteReader();
			for (int i=0; i<iNbProduits; i++) {
				if(_bd.Reader.Read()) {
				labels[i] = _bd.Reader["nom"].ToString();
			double y=double.Parse(_bd.Reader["solde"].ToString());
//			y [i]= Math.Sin( (double)_bd.Reader["solde"]);
			//list1.Add(y,y);
				}//if
			}//for i
			_bd.Reader.Close();
	       LineItem myCurve = myPane.AddCurve( "solde",
			                      list1, Color.Red,SymbolType.Diamond );
 			zgc.AxisChange();
		}


所以问题恰恰在于链接到数据库的一部分!!
http://www.codeproject.com/KB/graphics/zedgraph.aspx


so problem exactly in the part of linking to database!!
http://www.codeproject.com/KB/graphics/zedgraph.aspx

推荐答案

我在任何地方都看不到您要在其中打开连接的代码.

实际上,您专门关闭了一行,然后尝试在四行之后再次使用它,而无需再次打开它.

查看MSDN中的相关页面 [
I cannot see anywhere in your code where you are opening the connection.

In fact, you specifically close it in one line and then try to use it again 4 lines later, without having opened it again.

Take a look at the relevant page from MSDN[^].


这篇关于如何将zedgraph图表与mysql数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆