Good morning, I'm developing a code that can defer the X and Y values of a chart I inserted into ASP.NET. For this I made a query to the sql server to be returned to the average of a column, until the following error appeared: Can not find column 22276451. I need your help to solve this problem.
Here is the code:
protected void Chart1_Load6(object sender, EventArgs e)
{
String connectionString =
"Data Source=localhost;" +
"Initial Catalog=DB_SACC;" +
"User id=sa;" +
"Password=1234;";
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand();
string textt = " SELECT AVG (Total_Divida) FROM t_pagamentos";
cmd.CommandText = textt;
connection.Open();
cmd.Connection = connection;
cmd.CommandType = CommandType.Text;
decimal average = (decimal)cmd.ExecuteScalar();
Chart1.Series["Series1"].YValueMembers = "Banco";
Chart1.Series["Series1"].XValueMember =Convert.ToString( average);
}