【Vegas原创】调用不带参数的procedure代码
适合经常改变where子句的代码
SQL:
create proc procBP_Cost_UpdateCost
as
SELECT a.ModelGroupID, a.ProductCost
FROM T_ProductCost AS a INNER JOIN
T_BPCost ON a.ModelGroupID = T_BPCost.ModelGroupID
WHERE EXISTS (
SELECT MAX(CONVERT(int, PCYear + PCMonth)) AS Version, ModelGroupID
FROM T_ProductCost
GROUP BY ModelGroupID, ProductCostID
HAVING (MAX(CONVERT(int, PCYear + PCMonth)) = CONVERT(int, a.PCYear + a.PCMonth)) AND (a.CostCommit = 'Y'))
as
SELECT a.ModelGroupID, a.ProductCost
FROM T_ProductCost AS a INNER JOIN
T_BPCost ON a.ModelGroupID = T_BPCost.ModelGroupID
WHERE EXISTS (
SELECT MAX(CONVERT(int, PCYear + PCMonth)) AS Version, ModelGroupID
FROM T_ProductCost
GROUP BY ModelGroupID, ProductCostID
HAVING (MAX(CONVERT(int, PCYear + PCMonth)) = CONVERT(int, a.PCYear + a.PCMonth)) AND (a.CostCommit = 'Y'))
后台:
DataSet ds = db.GetDataSetbyProc("procBP_Cost_UpdateCost");
public DataSet GetDataSetbyProc(string procName)
{
#region 注释
/*********************************************\
*功能:
* 执行存储过程,返回DataSet
*返回: DataSet
Vegas 2008 07 16
\********************************************/
#endregion
SqlDataAdapter sda = new SqlDataAdapter(procName, connStr);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
sda.Fill(ds);
return ds;
}
{
#region 注释
/*********************************************\
*功能:
* 执行存储过程,返回DataSet
*返回: DataSet
Vegas 2008 07 16
\********************************************/
#endregion
SqlDataAdapter sda = new SqlDataAdapter(procName, connStr);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
sda.Fill(ds);
return ds;
}
喜欢请赞赏一下啦^_^