下面是存储过程哪里错误了呢
调用存储过程public int SelectCount(string strWhere)
{
int theValue;
using (SqlConnection myConnection = new SqlConnection(UserCenterConfiguration.Default.DbConnectionString))
{
using (SqlCommand command = new SqlCommand("usp_Get_BlogAttentionCount", myConnection))
{
= CommandType.StoredProcedure;
command.Parameters.Add("@count", SqlDbType.Int);
command.Parameters.Add("@strWhere", SqlDbType.NVarChar, 500, strWhere);
command.Parameters["@count"].Direction = ParameterDirection.Output;
try
{
command.ExecuteNonQuery();
theValue = (int)command.Parameters["@count"].Value;
myConnection.Close();
}
catch
{
myConnection.Close();
theValue = 0;
}
return theValue;
}
}
}
下面是存储过程
ALTER procedure [dbo].[usp_Get_BlogAttentionCount]
(
@strWhere nvarchar(500)='',
@count int output
)
as
declare @sqlStr nvarchar(1000)
if @strWhere != ''
set @sqlStr = N'select @COUNT = count(id) from BlogAttention where 1=1 ' + @strWhere
else
set @sqlStr = N'select @COUNT = count(id) from BlogAttention'
exec sp_executesql @sqlStr,N'@count int output',@count output