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