private DataTable GetData() { DataTable dtChartData = new DataTable();
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbx"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("usp_ChartData6", conn)) { cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
dtChartData.Load(reader); } }
return dtChartData; } } }
Stored Procedure: usp_ChartData6
CREATE PROCEDURE usp_ChartData6 AS BEGIN
SELECT COUNT(StudentId) * 1.0 /(SELECT COUNT(StudentId) FROM [dbo].[Students]) AS 'Total' ,Gender AS 'Gender' FROM [dbo].[Students] GROUP BY Gender
Comments
Post a Comment