- 爱易网页
-
ASP.NET教程
- SqlDataSource与分页存储过程参数有关问题(高分求救)
日期:2014-05-18 浏览次数:20538 次
SqlDataSource与分页存储过程参数问题(高分求救)
定义如下存储过程:
CREATE PROCEDURE GetCustomer_1
@tblName varchar(255), -- 表名
@strGetFields varchar(1000) = '* ', -- 需要返回的列
@fldName varchar(255)= ' ', -- 排序的字段名
@PageSize int = 10, -- 页尺寸
@PageIndex int = 1, -- 页码
@doCount int = 0, -- 返回记录总数, 非 0 值则返回
@OrderType int = 0, -- 设置排序类型, 非 0 值则降序
@strWhere varchar(1500) = ' ' -- 查询条件 (注意: 不要加 where)
AS...................
在后台代码中有如下代码:
DsForPager.ConnectionString = ConfigurationManager.ConnectionStrings[ "MySqlServer "].ConnectionString;
DsForPager.SelectParameters.Add( "tblName ", TypeCode.String, "tb_customer,tb_groupnameforcustomer ");
DsForPager.SelectParameters.Add( "strGetFields ", TypeCode.String, "* ");
DsForPager.SelectParameters.Add( "fldName ", TypeCode.String, " ");
DsForPager.SelectParameters.Add( "PageSize ", TypeCode.Int32, "3 ");
DsForPager.SelectParameters.Add( "PageIndex ", TypeCode.Int32, "1 ");
DsForPager.SelectParameters.Add( "doCount ", TypeCode.Int32, "0 ");
DsForPager.SelectParameters.Add( "OrderType ", TypeCode.Int32, "1 ");
DsForPager.SelectParameters.Add( "strWhere ", TypeCode.String, "tb_customer.groupid=tb_groupnameforcustomer.groupid ");
DsForPager.SelectParameters[ "tblName "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "strGetFields "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "fldName "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "PageSize "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "PageIndex "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "doCount "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "OrderType "].Direction = ParameterDirection.Input;
DsForPager.SelectParameters[ "strWhere "].Direction = ParameterDirection.Input;