I am a novice to C# chart control. I have read the samples and examples code from msdn about chart. In one of the example, OledbDataReader is bind to chart control. But in my program, I use SqlDataReader. I assume there is no big difference between OledbDataReader and SqlDataReader in this situation. When I made SqlDataReader binding to Chart, I got the error

"Invalid attempt to read when reader is close".

My program code is as follow:

From DataReader Class

public sqlDataReader SelectData()
{
   //sqlstatement...
   return sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
}

From ChartControl Form

DataReader dr = new DataReader();
SqlDataReader yvalues = dr.SelectData();
string[] xval = { "7am", "8am", "9am", "10am", "11am" };

chart1.Series["Series1"].Points.DataBindXY(xval, yvalues);  //at here error occured

Sorry for my poor english...if anyone knows the solution, please help me...thanks in advance

share|improve this question
Did You try to look into the "yvalues" with the debugger ? From what I see in Your questions, seems to me that Your usage of DataReader is missing something – Marty Sep 1 '12 at 18:14

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.