日期:2014-05-20  浏览次数:20536 次

存储过程的问题,附源码,长
retail.ascx.cs代码:
using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;
using   jxdom.DBUtility;
using   System.Data.SqlClient;


public   partial   class   Controls_retail   :   System.Web.UI.UserControl
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                if   (!IsPostBack)
                {
                        int   totalOrders   =   (int)jxdom.DBUtility.SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringLocalTransaction,   CommandType.StoredProcedure,   "P_GetorderNumber ");//这句不懂怎么写才对,提示这里出错:过程   'P_GetOrderNumber '   需要参数   '@pageindex ',但未提供该参数。  
                                AspNetPager1.RecordCount   =   totalOrders;

                }
        }

}

retail.ascx代码:
<asp:SqlDataSource   ID= "SqlDataSource3 "   runat= "server "   ConnectionString= " <%$   ConnectionStrings:SQLConnString1   %> "
      SelectCommand= " <%$   AppSettings:pagedSPName   %> "   SelectCommandType= "StoredProcedure ">
        <SelectParameters>
                <asp:Parameter   DefaultValue= "true "   Name= "IsShow "   Type= "Boolean "   />
                                        <asp:ControlParameter   ControlID= "AspNetPager1 "   DefaultValue= "10 "   Name= "pagesize "
                                PropertyName= "PageSize "   Type= "Int32 "   />
                        <asp:ControlParameter   ControlID= "AspNetPager1 "   DefaultValue= "1 "   Name= "startIndex "
                                PropertyName= "StartRecordIndex "   Type= "Int32 "   />
        </SelectParameters>
</asp:SqlDataSource>


存储过程:
CREATE   procedure   P_GetOrderNumber  
(@pagesize   int,
@pageindex   int,
@docount   bit)
as
set   nocount   on
if(@docount=1)
select   count(PaiXu)   from   Item   where   isshow=1
else
begin
declare   @indextable   table(id   int   identity(1,1),nid   int)
declare   @PageLowerBound   int
declare   @PageUpperBound   int
set   @PageLowerBound=(@pageindex-1)*@pagesize