I have a problem with displaying data from a column that is in SQL Server, to insert as x and y in my chart in asp.net the problem is this, so it seems the method (DataBindTable) is waiting for IEnumerable But my SqlDataReader does not implement IEnumerable. If you could give me examples of how to overcome this difficulty, thank you.
Here is the insertion code:
protected void Chart1_Load13(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("SELECT [Consumo_Medio_Real], [Tipo_de_Fatura] FROM [dbo].[t_faturas]", con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
Chart1.DataBindTable(rdr,"Consumo_Medio_Real");
}
}
This is the connection code:
<connectionStrings>
<add name="CS" connectionString="Data Source=ASUS;Initial
Catalog=DB_SACC;Persist Security Info=True;User ID=sa;Password=1234"
providerName="System.Data.SqlClient" />
</connectionStrings>