0
Answer

How to returns a value from stored procedure in ASP.NET

Hello! I have been trying to find an answer to my dillema for some time now, I hope that I can find an answer here. My dillema is that I am trying to return a value from a stored procedure. The prcedure is a simple count of records entered "today". This will then populate a variable in the Page_load of an ASP page. I then check the variable to see if there are any records, if there are then query the database to get the records. Some of the code I am using. This is the Class that has the connectionstring and parameters for the SP. public static string GetDailyCallCount(out int howManyCalls) { DbCommand comm = GenericDataAccess.CreateCommand(); comm.CommandText = "CountCalls"; DbParameter param = comm.CreateParameter(); param.ParameterName = "@HowManyCallsToday"; param.Direction = ParameterDirection.InputOutput; param.DbType = DbType.Int16; comm.Parameters.Add(param); //DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); comm.Parameters["@HowManyCallsToday"].Direction = ParameterDirection.Output; int HowManyCallsToday; GenericDataAccess.ExecuteSelectCommand(comm); HowManyCallsToday = Int32.Parse(comm.Parameters["@HowManyCallsToday"].Value.ToString()); return HowManyCallsToday; //error can not implicitly convert int to string } This is the calling code. int howManyCalls = GetDailyCallCount(out howManyCalls); Help please.