this is myCode:
private void frmChart_Load(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString;
using (SqlConnection Con = new SqlConnection(cs))
{
SqlCommand cmdSum = new SqlCommand("Select distinct(UserName),sum(Value) from mytable group by UserName",Con);
Con.Open();
SqlDataReader reader = cmdSum.ExecuteReader();
chart1.DataBindTable(reader,"sum(Value)");
}
foreach (Series series in chart1.Series)
{
series.CustomProperties = "DrawingStyle=LightToDark";
}
}
It shows me an error in chart1.DatabindTable. also I try another method but I could not handle it.
check you values into reader.. if you have values,
try replacing
with
once you sum up values into query you need not to mention sum again, your Value parameter will have sum
Edit --- Updated Code..
If all you're trying to do is to bind a data table, then just do this:
Note when calling
DataBindTable
you have to use "UserName" (xField
). NotValue
orSum(Value)
.