首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

SqlDataSource与分页存储过程参数有关问题(高分求救)

2012-02-08 
SqlDataSource与分页存储过程参数问题(高分求救)定义如下存储过程:CREATEPROCEDUREGetCustomer_1@tblNamev

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;
                DsForPager.SelectCommand   =   "getCustomer_1 ";


                DsForPager.SelectCommandType   =   SqlDataSourceCommandType.StoredProcedure;
                gridView.DataSource   =   DsForPager;
gridView.DataBind();
现出现问题如下:
在SQL的查询分析器中直接调用存储过程:exec   getCustomer_1   'tb_customer,tb_groupnameforcustomer ', '* ', ' ',5,1,0,1, 'tb_customer.groupid=tb_groupnameforcustomer.groupid '         可以获得相关的记录,但是把参数添加到SqlDataSource控件上对dataview进行绑定却没有相应的记录显示


[解决办法]
直接写老实的查询SQL,GridView自己会处理分页。如果需要大大提高效率,学习GridView的“允许缓存”属性相关的设置。
[解决办法]
高效 2分查找 分页存储过程
http://blog.csdn.net/hertcloud/category/281167.aspx
[解决办法]
不用SqlDataSource控件,用查询语句吧

热点排行