Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144095 | Apr 18,2019 08:05 AM UTC | Apr 24,2019 12:30 PM UTC | ASP.NET Web Forms | 5 |
![]() |
Tags: Chart |
protected void Page_Load(object sender, EventArgs e)
{
Series series1 = new Series();
Series series2 = new Series();
List<ChartSqlData> data = new List<ChartSqlData>();
string connectionString = null;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet dataset = new DataSet();
connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=false;Connect Timeout=100;";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string command2 = "SELECT * FROM [Products] WHERE UnitPrice < 10";
SqlCommand cmd1 = new SqlCommand(command2, con);
adapter.SelectCommand = cmd1;
adapter.Fill(dataset);
for (var i = 0; i < dataset.Tables[0].Rows.Count; i++)
{
string x1 = Convert.ToString(dataset.Tables[0].Rows[i]["ProductName"]);
double y1 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitPrice"]);
double y2 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitsInStock"]);
data.Add(new ChartSqlData(x1, y1, y2));
}
this.Chart1.DataSource = data;
this.Chart1.DataBind();
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.