Sqlce's DBRedirectList's GetPage always return the 1st page

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/30/2013 5:26:09 AM
Gravatar
Total Posts 46

Sqlce's DBRedirectList's GetPage always return the 1st page

Hi, joe

 the code in mojoPortal.Data.SqlCe\DBRedirectList.cs, line 374:

////////////////////////////////////////////begin //////////////////////////////////////////////////////

public static IDataReader GetPage(

.....

            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  "); sqlCommand.Append("t1.OldUrl DESC  ");

            sqlCommand.Append(") AS t2 ");

.............................................

////////////////////////////////////////////end //////////////////////////////////////////////////////

I think you need uncomment the line

//sqlCommand.Append("ORDER BY  ");

and just like the codes in DBFriendlyUrl.cs, change this line to

sqlCommand.Append("ORDER BY  "); 

sqlCommand.Append("t1.OldUrl DESC  ");

otherwise this paging sql will always return the 1st page.

Thanks.

5/30/2013 12:36:34 PM
Gravatar
Total Posts 18439

Re: Sqlce's DBRedirectList's GetPage always return the 1st page

Can you try those changes and confirm if they solve the problem? or suggest a different solution if it doesn't

Thanks,

Joe

5/30/2013 3:03:19 PM
Gravatar
Total Posts 46

Re: Sqlce's DBRedirectList's GetPage always return the 1st page

    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!.

5/30/2013 3:15:40 PM
Gravatar
Total Posts 18439

Re: Sqlce's DBRedirectList's GetPage always return the 1st page

This fix is now in the source code repository.

Thanks!

Joe

You must sign in to post in the forums. This thread is closed to new posts.