create & call stored procedure in ASP.NET 2.0 & MSSQL DB
<--CREATE-->
ALTER PROCEDURE dbo.NumOfRecords
AS
SELECT COUNT(*) FROM Branding
RETURN
<--CALL-->
protected void Button8_Click(object sender, EventArgs e)
{
SqlConnection newConn = new SqlConnection("Data Source=localhost;Initial Catalog=TCdatabase;Integrated Security=True;Pooling=False");
SqlCommand newComm = new SqlCommand("NumOfRecords", newConn);
newConn.Open();
int theTotal = (Int32)newComm.ExecuteScalar();
Response.Write(theTotal.ToString());
newConn.Close();
}
No comments:
Post a Comment