C# Code
using System;
using System.Data;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
namespace ChartDemoVC2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SalesByYearChart.DataSource = GetData();
SalesByYearChart.Series["SalesByYear"].XValueMember = "Year";
SalesByYearChart.Series["SalesByYear"].YValueMembers = "Total";
}
private DataTable GetData()
{
DataTable dtData = new DataTable();
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbx"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("usp_ChartData", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
dtData.Load(reader);
}
}
return dtData;
}
}
}
Stored Procedure: [dbo].[usp_ChartData]
CREATE PROCEDURE [dbo].[usp_ChartData]
AS
BEGIN
SELECT SUM(Total) AS 'Total'
,DATEPART(yyyy, [DateOfOrder]) AS 'Year'
FROM [dbo].[Orders]
GROUP BY DATEPART(yyyy, [DateOfOrder])
END
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 :