HI I am using
- ASP.Net
- C#
- SQL Server Express 2008 R2
I have a table called customers which contains all customer details and a stored procedure which gets:
- Total No Of Customers
- Total No Of Customers in Region1
- Total No Of Customers in Region2
etc etc...
I would like to then populate these results into a "statistics" page on my site/app using the label control (or any other method if easier).
So far I have the Stored Procedure:
CREATE PROCEDURE [usp_getStats]
AS
-- Count Region1 Accounts
SELECT COUNT(custID) FROM custDetail WHERE region = '1'
-- Count Southern Accounts
SELECT COUNT(custID) FROM custDetail WHERE region = '2'
--Count Total Accounts
SELECT COUNT(custID) FROM custDetail
--Count Total Pending Accounts
SELECT COUNT(custID) FROM custDetail WHERE accountCreated='1'
--Count Total Inactive Accounts
SELECT COUNT(custID) FROM custDetail WHERE accountLive = '1'
--Count Total backup Usage Region1
SELECT SUM(quota) FROM custDetail WHERE region='1'
--Count Total backup Usage Region2
SELECT SUM(quota) FROM custDetail WHERE region='2'
--Count Total Backup Usage Total
SELECT SUM(quota) FROM custDetail
Code Behind for page is;
public partial class backupstats : System.Web.UI.Page
{
DataSet ds = new DataSet();
SqlConnection con;
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection("Data Source=SERVERNAME\\SQLEXPRESS2008;Initial Catalog=DBNAME;Integrated Security=SSPI");
cmd = new SqlCommand("usp_getBackupStats", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet data = new DataSet();
da.Fill(data);
//To add code here that populates labels....
label1.text = ???
}
}
Do I need to create seperate variables in the Stored Proc and then call them from C# code?
If so could somebody give me an example or point me towards a tutorial, I have searched quite a bit on this.
thanks very much
Dwayne