Hello I would like to ask how to use Dynamic Order By in Stored Proc using MySQL.
http://www.aspsnippets.com/Articles/Custom-Paging-in-ASPNet-GridView-using-MySql-Stored-Procedure.aspx
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCustomers_Pager`(
_PageIndex INT
,_PageSize INT
,_SortExpression VARCHAR(50)
,_SortDirection VARCHAR(50)
,OUT _RecordCount INT
)
BEGIN
SET @RowNumber:=0;
CREATE TEMPORARY TABLE Results
SELECT @RowNumber:=@RowNumber+1 RowNumber
,CustomerID
,ContactName
,CompanyName
FROM Customers;
SET _RecordCount =(SELECT COUNT(*) FROM Results);
SELECT * FROM Results
WHERE RowNumber BETWEEN(_PageIndex -1) * _PageSize + 1 AND(((_PageIndex -1) * _PageSize + 1) + _PageSize) - 1;
DROP TEMPORARY TABLE Results;
END$$
DELIMITER ;
I've been Stock on how to apply the SORTEXPRESSION and SORTDIRECTION.
Thanks!