0
Good morning, I’m developing a code that can accept the X and Y values of a Chart I entered in Asp.net. For this I made a query to sql server so that it could be returned to a column media, until the following error : It is not possible to locate column 22276451. I need your cooperation to solve this problem.
Here follows 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);
}
You will need more information, please add the structure/script creation of the t_payments table.
– Pedro Ferreira
the structure was created in sql is not relevant to the case , but perhaps it is relevant to inform that this code is associated to a Chart with a link to my database maybe that is the problem .
– Diogo Gomes
"Unable to locate column 22276451", the structure is not suitable to select...
– Pedro Ferreira
Pedro I tested the query in the sql database and this functional
– Diogo Gomes
Ok, if the sql component is functional, it should be Chart1.Series, shows the component where you add Serie, Chart1.Series.Add("Series1"); this exists?
– Pedro Ferreira
this in the code I put in the initial question. That’s the code I’m using.
– Diogo Gomes
Yes, but in order for Chart1 to have a series with the name "Series1" you need the command I mentioned, and in the code above I don’t see any initialization.
– Pedro Ferreira
Could you give me a practical example ? Thank you!
– Diogo Gomes