hi, joe.
the above change can show the 2st page, but the result is in the desc order, so another place need change too.
So there are two places need be changed:
///////////////////////////////////////// begin /////////////////////////////////////////////////////
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT * FROM ");
sqlCommand.Append("(");
sqlCommand.Append("SELECT TOP (" + pageSize.ToString(CultureInfo.InvariantCulture) + ") * FROM ");
sqlCommand.Append("(");
sqlCommand.Append("SELECT TOP (" + pageNumber.ToString(CultureInfo.InvariantCulture) + " * " + pageSize.ToString(CultureInfo.InvariantCulture) + ") * ");
sqlCommand.Append("FROM mp_RedirectList ");
sqlCommand.Append("WHERE ");
sqlCommand.Append("SiteID = @SiteID ");
sqlCommand.Append("ORDER BY ");
sqlCommand.Append("OldUrl ");
sqlCommand.Append(") AS t1 ");
//sqlCommand.Append("ORDER BY "); => sqlCommand.Append("ORDER BY t1.OldUrl DESC");
sqlCommand.Append(") AS t2 ");
//sqlCommand.Append("WHERE ");
//sqlCommand.Append("ORDER BY "); => sqlCommand.Append("ORDER BY t2.OldUrl");
sqlCommand.Append(";");
///////////////////////////////////////// end /////////////////////////////////////////////////////
After changed, the complete codes are below:
///////////////////////////////////////// begin /////////////////////////////////////////////////////
StringBuilder sqlCommand = new StringBuilder();
sqlCommand.Append("SELECT * FROM ");
sqlCommand.Append("(");
sqlCommand.Append("SELECT TOP (" + pageSize.ToString(CultureInfo.InvariantCulture) + ") * FROM ");
sqlCommand.Append("(");
sqlCommand.Append("SELECT TOP (" + pageNumber.ToString(CultureInfo.InvariantCulture) + " * " + pageSize.ToString(CultureInfo.InvariantCulture) + ") * ");
sqlCommand.Append("FROM mp_RedirectList ");
sqlCommand.Append("WHERE ");
sqlCommand.Append("SiteID = @SiteID ");
sqlCommand.Append("ORDER BY OldUrl");
sqlCommand.Append(") AS t1 ");
sqlCommand.Append("ORDER BY t1.OldUrl DESC");
sqlCommand.Append(") AS t2 ");
sqlCommand.Append("ORDER BY t2.OldUrl");
sqlCommand.Append(";");
///////////////////////////////////////// begin /////////////////////////////////////////////////////
I have test the above code in my computer, it just works.
Thanks!.