Today, I will explain to you How to use stored Procedure with output parameters with ASP.NET. I have given a basic code case, I have made a store technique with yield parameter. After that I get it from code behind page of asp.net and put away it a variable.

private void GetInfo() 
   { 
     DALUtility objDALUtility = null; 
     SqlConnection con = null; 
     SqlCommand cmd = null; 
     SqlDataAdapter da = null; 
     try 
     { 
       objDALUtility = new DBUtility(ConfigurationManager.AppSettings["myconString"]); 
       con = objDALUtility.GetDBConnection(); 
       con.Open(); 
       cmd = new SqlCommand(); 
       cmd.Connection = con; 
       cmd.CommandType = CommandType.StoredProcedure; 
       cmd.CommandTimeout = 500; 
       cmd.CommandText = "usp_MyInfo"; 
       cmd.Parameters.AddWithValue("@Id", strId); 
       cmd.Parameters.AddWithValue("@empName", Convert.ToString(Session["Name"]));       
       cmd.Parameters.Add("@TotalCount", SqlDbType.Int).Direction = ParameterDirection.Output; 
       da = new SqlDataAdapter(cmd); 
       DataSet objDS = new DataSet("MyInfo"); 
       da.Fill(objDS); 
       con.Close(); 
       int Total = Convert.ToInt32(cmd.Parameters["@TotalCount"].Value); 
     } 
   } 
 Stored Procedure 
 CREATE Proc [dbo].[usp_MyInfo] 
  @Id int,           
  @Name varchar(50) = null,     
  @Total int = 0 OUTPUT 
 AS         
 SET @Total = (Select COUNT(Distinct tbl_Logs.ContentId) From tbl_Logs with(nolock)        
  Inner Join tbl_Logs_details with(nolock) on tbl_Logs_details.ContentId = tbl_Logs.ContentId 
  Where id = @id and tbl_Logs_details.ContentId = 2  
 Select @Total as Count

Finish, just paste that code, your ASP.NET problems solved. Hopefully, it will solve your ASP.NET problems. Any questions, comment here!

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers SSRS hosting starts from $5/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable SSRS Hosting, ASPHostPortal.com should be your best choice.