Here is my records like in the table below. sql query
My SQL query is
select Category_NM as 'Kategoriler', avg(Payment) as 'Ortalamalar'
from Islem
where Category_Type = 'Gider'
group by Category_NM
And my code:
public SqlDataReader DataReader(string Query_)
{
SqlCommand cmd = new SqlCommand(Query_, con);
SqlDataReader dr = cmd.ExecuteReader();
return dr;
}
and
SqlDataReader dr = sınıf.DataReader("select Category_NM as 'Kategoriler',AVG(Payment) as 'Ortalamalar' from Islem where Category_Type = 'Gider' group by Category_NM");
dr.Read();
chart1.Series[0].IsValueShownAsLabel = true;
while (dr.Read())
{
// MessageBox.Show(Convert.ToString(dr[0]+""+dr[1]));
chart1.Series[0].Points.AddXY(dr[0],dr[1]);
}
dr.Close();
The problem ıs reader does not read all records - like this:
dr[2]? Since you only posted part of an image it's impossible to see whether the SQL query includes all columnsusingblocks in order to correctly dispose them. Do not cache the connection object.