hvorfor forbliver mit inputoutput parameter 0
Hvad gør jeg forkert siden totalrecords forbliver 0 - hvis jeg kører den "stored procedure" inde fra visual studio med samme parametre returnerer totalrecords rigtigt...public DataTable GetPagedNews(int currentPage, int pageSize, ref int totalRecords)
{
SqlConnection connection = null;
connection = GetConnection();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.Connection = GetConnection();
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "dbo.GetNews";
DataTable results = new DataTable("News");
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
try
{
sqlCommand.Parameters.Add(new SqlParameter("currentPage",currentPage));
sqlCommand.Parameters.Add(new SqlParameter("pageSize",pageSize));
SqlParameter sqlParameter = new SqlParameter("@TotalRecords", SqlDbType.Int);
sqlParameter.Value = totalRecords;
sqlParameter.Direction = ParameterDirection.InputOutput;
sqlCommand.Parameters.Add(sqlParameter);
sqlCommand.Connection.Open();
sqlDataAdapter.Fill(results);
return results;
}
catch (Exception ex)
{
throw ex;
}
finally
{
sqlDataAdapter.Dispose();
sqlCommand.Connection.Close();
sqlCommand.Dispose();
}
}