Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.
C#
             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();
		}

so problem exactly in the part of linking to database!!
http://www.codeproject.com/KB/graphics/zedgraph.aspx
Posted
Updated 11-Mar-11 11:50am
v2

1 solution

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[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900