C# 得到存储过程返回值
--存储过程
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[WebSite_ExitsSiteID]
@siteid bigint
AS
BEGIN
if exists(select id from WebSite where SiteID = @SiteID)
return 1
else
return 2
END
--C#代码
/// <summary>
/// 检查站点标识是否存在
/// </summary>
/// <param name="id">站点标识</param>
/// <returns></returns>
public bool SelectSiteID(long id)
{
SqlParameter[] paras = new SqlParameter[]{
new SqlParameter("@siteid",SqlDbType.BigInt),
new SqlParameter("@@RETURN_VALUE",SqlDbType.Int,4)
};
paras[0].Value = id;
paras[1].Direction = ParameterDirection.ReturnValue;
SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString, CommandType.StoredProcedure, "WebSite_ExitsSiteID", paras);
int result = int.Parse(paras[1].Value.ToString());
if (result == 1)
{
return true;
}
else
{
return false;
}
}

浙公网安备 33010602011771号