Code is below.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Chart3
{
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 = "Gender";
Chart1.Series["Series1"].YValueMembers = "Total";
Chart1.DataBind();
}
// Object, Array, Collection, Generic, DataSet, DataTable
private DataTable GetData()
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbx"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("usp_Chart3", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable dtData = new DataTable();
dtData.Load(reader);
return dtData;
}
}
}
}
}
Stored Procedure: usp_Chart3
CREATE PROCEDURE usp_Chart3
AS
BEGIN
SELECT COUNT(StudentId) * 1.0 / (SELECT COUNT(StudentId) FROM [dbo].[Students]) AS 'Total'
,Gender AS 'Gender'
FROM [dbo].[Students]
GROUP BY Gender
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 :