小弟我写了一个存储过程,请高手看看,有没有那个地方有错,或者有更好的办法
CREATE PROCEDURE order_tot_amt
@o_shopcode int,--店铺编号
@n_name varchar(50),--用户姓名@d_begindate DateTime,--开始时间
@d_enddate DateTime,--结束时间@p_totnum int output,--总数量
@p_totamount int output--总金额@p_tienum int output,--搭配数量
@p_tieamount int output--搭配金额@p_tienumpro int output,--搭配数量率
@p_tieamountpro int output--搭配金额率AS
--查询 总数量@p_totnum,总金额@p_totamout。
select @p_totnum=sum(sell_Salenum) as 总数量,@p_totamout=sum(sell_totalamount) as 总金额  
from dmsshopsell,cusgroup, CUSGROUPSETING where 
dmsshopsell.shop_Code like '%'+rtrim(@o_shopcode)+'%' and (sell_saledate between @d_begindate and @d_enddate)
and dmsshopsell.shop_code = cusgroupseting.shop_code and cusgroup.group_Id = CUSGROUPSETING.group_id and group_name = @n_name
group by dmsshopsell.shop_Code
--查询 搭配数量@p_tienum,搭配金额@p_tieamount----------------------------------------------------------------------------------
select @p_tienum=sum(sell_Salenum)as 搭配数量,@p_tieamount=sum(sell_totalamount) as 搭配金额  
from dmsshopsell,cusgroup, CUSGROUPSETING where 
dmsshopsell.shop_Code like '%'+rtrim(@o_shopcode)+'%' and (sell_saledate between @d_begindate and @d_enddate) and sell_salenum>=2 
and dmsshopsell.shop_code = cusgroupseting.shop_code and cusgroup.group_Id = CUSGROUPSETING.group_id and group_name = @n_name
group by dmsshopsell.shop_Code
--将搭配数量率和搭配金额率算出,并插入新表tiepro-----------------------------------------------------------------------------
INSERT INTO tiepro VALUES shop_code=@o_shopcode,tienumpro = @p_tienum/@p_totnum ,tiemoney = @p_tieamount/@p_totamount
--查询 搭配数量率@p_tienumpro,搭配金额率@p_tieamountpro-------------------------------------------------------------------------
select @p_tienumpro=tienumpro,@p_tieamountpro=tiemoney from tiepro where shop_code=@o_shopcodeGO 
我asp.net页面想用repeter来绑定数据,那么我Eval  的参数是什么呢?
注释都很清楚,有问题也可以QQ联系,也欢迎高手指教!309911833 !
邮箱[email protected].
大家有问题一起讨论
回答满意,还可以加分。

解决方案 »

  1.   

    Eval的参数就是你查询处理的对象的属性。
      

  2.   


    INSERT INTO tiepro VALUES shop_code=@o_shopcode,tienumpro = @p_tienum/@p_totnum ,tiemoney = @p_tieamount/@p_totamount这是什么语言?insert into [user] values (@ids,@name,@sex,@sate)
      

  3.   

    恩,我刚刚也发现了,要加()
    但是加了后却是这样在此上下文中不允许使用名称 "shop_code"。有效表达式包括常量、常量表达式和变量(在某些上下文中)。不允许使用列名。
      

  4.   

    过程或函数 'order_tot_amt' 需要参数 '@p_totnum',但未提供该参数。可是我的'@p_totnum' 不是output么?是不是和
    INSERT INTO tiepro VALUES (@o_shopcode,@p_tienum/@p_totnum ,@p_tieamount/@p_totamount)有关
      

  5.   

    output.Direction = ParameterDirection.Output; 
    参考
      

  6.   

    这个解决了DECLARE   @p_totnum_for   int 
    DECLARE   @p_totamount_for   int 
    DECLARE   @p_tienum_for   int 
    DECLARE   @p_tieamount_for   int 
    DECLARE   @p_tienumpro_for   int 
    DECLARE   @p_tieamountpro_for   int exec order_tot_amt @o_shopcode ='1', @n_name='戴超' ,@d_begindate='2010-1-1',@d_enddate='2011-1-1'
    ,@p_totnum =@p_totnum_for output,--总数量
    @p_totamount =@p_totamount_for output,--总金额@p_tienum =@p_tienum_for output,--搭配数量
    @p_tieamount =@p_tieamount_for output,--搭配金额@p_tienumpro =@p_tienumpro_for output,--搭配数量率
    @p_tieamountpro =@p_tieamountpro_for output--搭配金额率
     
    PRINT  Convert(varchar(50),@p_totnum_for) +'a'+ Convert(varchar(50),@p_totamount_for)  +'a'+ Convert(varchar(50),@p_tienum_for)  +'a'+ Convert(varchar(50),@p_tieamount_for)  +'a'+ Convert(varchar(50),@p_tienumpro_for)  +'a'+ Convert(varchar(50),@p_tieamountpro_for)
      

  7.   

    但是我如果模糊查询,查出2行记录,就显示不出来了INSERT INTO tiepro VALUES (@o_shopcode,@p_tienum/@p_totnum ,@p_tieamount/@p_totamount)
    select @p_tienumpro=tienumpro,@p_tieamountpro=tiemoney from tiepro where shop_code=@o_shopcode这里面,我得到的@p_tienumpro,@p_tieamountpro 都是0,
      

  8.   


    INSERT INTO tiepro VALUES (@o_shopcode,@p_tienum/@p_totnum ,@p_tieamount/@p_totamount)
    select @p_tienumpro=tienumpro,@p_tieamountpro=tiemoney from tiepro where shop_code=@o_shopcode
    你的问题是,你values,前面没有参数的,也就是说你再values后面括号中要给每个字段都赋上值,没值的你也要给个空啊?你的@p_tienum/@p_totnum ,应该没有插入到tienumpro这个字段中,只是放到了第二个字段上了,你直接select *from tiepro 看看,你的值是不是进去了、