Code is below.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Chart1
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
Chart1.DataSource = GetData();
Chart1.Series["Series1"].XValueMember = "Year";
Chart1.Series["Series1"].YValueMembers = "Total";
Chart1.DataBind();
}
private DataTable GetData()
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbx"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("usp_Chart1", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable dtData = new DataTable();
dtData.Load(reader);
return dtData;
}
}
}
}
}
Stored Procedure: usp_Chart1
CREATE PROCEDURE [dbo].[usp_Chart1]
AS
BEGIN
SELECT SUM(Total) AS 'Total'
,DATEPART(yyyy, DateOfOrder) AS 'Year'
FROM [dbo].[Orders]
GROUP BY DATEPART(yyyy, DateOfOrder)
HAVING DATEPART(yyyy, DateOfOrder) >= 1980 AND DATEPART(yyyy, DateOfOrder) <= 1985
END
GO
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :