------------------------------------------------------CREATE PROCEDURE proc_RecordCount
(
@rsCount int output )AS EXEC ('select @rsCount=count(id) from BusinessChance' )
GO'---------------------------------------------------
我想返回@rsCount 我下面这样写正确吗?SqlConnection MyConn=new SqlConnection(conn_Default);
SqlCommand cmd = new SqlCommand("proc_RecordCount",MyConn);MyConn.Open();// 废置SqlCommand的属性为存储过程
cmd.CommandType = CommandType.StoredProcedure;cmd.Parameters.Add("@rsCount", SqlDbType.Int, 4);cmd.Parameters["@rsCount"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();System.Web.HttpContext.Current.Response.Write(cmd.Parameters["@rsCount"].Value);MyConn.Close();
MyConn.Dispose();
我想返回@rsCount 我上面这样写正确吗?
(
@rsCount int output )AS EXEC ('select @rsCount=count(id) from BusinessChance' )
GO'---------------------------------------------------
我想返回@rsCount 我下面这样写正确吗?SqlConnection MyConn=new SqlConnection(conn_Default);
SqlCommand cmd = new SqlCommand("proc_RecordCount",MyConn);MyConn.Open();// 废置SqlCommand的属性为存储过程
cmd.CommandType = CommandType.StoredProcedure;cmd.Parameters.Add("@rsCount", SqlDbType.Int, 4);cmd.Parameters["@rsCount"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();System.Web.HttpContext.Current.Response.Write(cmd.Parameters["@rsCount"].Value);MyConn.Close();
MyConn.Dispose();
我想返回@rsCount 我上面这样写正确吗?
直接CREATE PROCEDURE proc_RecordCount
(
@rsCount int output )AS select @rsCount=count(id) from BusinessChanceGO不行么?
CREATE PROCEDURE proc_RecordCount
@rsCount int output
AS
select @rsCount=count(id) from BusinessChance
GOC#代码不用改动
真不明白呀!