由于需要在(ASP.NET)网站的网格视图中显示记录。同样,我正在使用过程将数据返回到 .net 框架。
因为我的问题是我需要设置表并返回当前行的(数据)编号。页。而且我还需要总行数进行分页(显示页数)。
同样,我写了以下是我返回的程序
CREATE PROCEDURE usp_SearchEmp(IN _RowIndex int, IN _MaxRows int , IN _SortByCol varchar(40),IN _EmployeeID int)
DECLARE _getLastSequenceNumberSQL VARCHAR(4000);
set _getLastSequenceNumberSQL ='
SELECT SQL_CALC_FOUND_ROWS
@rownum:=@rownum+1 ROW,
E.EmployeeID,
E.EmployeeName
from
(SELECT @rownum:=0) r, Employee E ;
IF (_EmployeeID IS NOT NULL) THEN
set _getLastSequenceNumberSQL = concat(_getLastSequenceNumberSQL,' WHERE (E.EmployeeID=',_EmployeeID,')');
END IF;
IF (_SortByCol IS NOT NULL) AND (_SortByCol != "") THEN
set @SortCol = concat(' ORDER BY ', _SortByCol) ;
ELSE
set @SortCol = 'ORDER BY EmployeeName';
END IF;
set _getLastSequenceNumberSQL = concat(_getLastSequenceNumberSQL, @SortCol , ' LIMIT ', _RowIndex, ' , ' , _MaxRows,' ');
SET @getLastSequenceNumberSQL = _getLastSequenceNumberSQL;
prepare lastRecordStmt from @getLastSequenceNumberSQL;
execute lastRecordStmt;
deallocate prepare lastRecordStmt;
select FOUND_ROWS() as i;
但现在的问题是,当我从 .net 调用此过程时,它只返回 Found_Rows 的结果。
I need out put . some thing like the following
喜欢 :-
SELECT 64 AS `ROWMAX`, E.EmployeeID, E.EmployeeName FROM Employee E order by EmployeeID LIMIT 0 , 4
|--------------------------------------------------------------|
| ROWMAX | EmployeeID | EmployeeName |
|--------------------------------------------------------------|
| 64 | 1 | Emp One |
| 64 | 2 | Emp Two |
| 64 | 3 | Emp Three |
| 64 | 4 | Emp Four |
----------------------------------------------------------------
因为我可以使用 ROWMAX 列来证明网格视图中的页数。
所以请指导我。因为我是 MYSQL 的新手