Sqlpager final version [with source code and sample programs] (paging using stored procedures)

Source: Internet
Author: User
Nbsp; I have already written many articles about sqlpager Article Now, I will not talk about sqlpager! This is my final improvement on sqlpager!
The main improvement was based on the last modification of its style table designation and digital paging. The main modification was the paging method, which was always the select top paging, now I want to use the SQL stored procedure page! I encountered a lot of problems when using the original paging method. The most prominent problem was that I could not use the flying keyword segment sorting. So I made this modification this time, I believe that this modification can basically meet general requirements!
I don't need to post specific Code The code will be downloaded as an attachment for users who need it! Here, I only want to note some points. Here I write the call method, because it is a little different from the previous one.
Method for Data Binding: (a new comment is added)

/**/ /// <Summary>
///Bind data
/// </Summary>
/// <Param name = "SQL">SQL statement</Param>
Private   Void Bindgrid ( String SQL)
{
// Notes
/**/ /*
* 1. the sorting of only one field can be optimized. We hope you can improve the sorting.
* 2. If the string SQL query contains single quotes such as like '% JJ %', replace single quotes with single quotes such as like ''% JJ %''
* 3. The last where condition must be added. As for what to add, write as needed. If there are no conditions, you must write a condition, such as a primary key> 0.
**/
This . Bindsqlpager (sqlpager1, ljhsqlpager2.sortmode. ASC, " Orderid " , " Orderid " , This . Connectstring, " Datagrid1 " , SQL, " ( " + SQL + " ) " , " * " , " Orderid> 0 " );
}

/**/ ///   <Summary>
/// Page for binding sqlpager data stored procedure
///   </Summary>
///   <Param name = "sqlpager"> Sqlpager Control ID </Param>
///   <Param name = "sort"> Sorting Method </Param>
///   <Param name = "sortfied"> Sorting Field </Param>
///   <Param name = "fieldkey"> Key field (primary key) </Param>
///   <Param name = "connectstring"> Database link string </Param>
///   <Param name = "controlname"> Bound Grid Control </Param>
///   <Param name = "commandtext"> SQL statement </Param>
///   <Param name = "tablename"> Name of a data table (which can be a complex query) </Param>
///   <Param name = "fields"> Query Fields </Param>
///   <Param name = "sqlcondition"> Where condition </Param>
Public   Void Bindsqlpager (ljhsqlpager2.sqlpager sqlpager, ljhsqlpager2.sortmode sort,
String Sortfied, String Fieldkey, String Connectstring, String Controlname, String Commandtext,
String Tablename, String Fields, String Sqlcondition)
{
Sqlpager. connectionstring = Connectstring;
Sqlpager. controltopaginate = Controlname;
Sqlpager. selectcommand = Commandtext;
Sqlpager. sortmode = Sort;
Sqlpager. fieldkey = Fieldkey;
Sqlpager. sortfield = Sortfied;
Sqlpager. tablename = Tablename;
Sqlpager. Fields = Fields;
Sqlpager. sqlcondition = Sqlcondition;
Sqlpager. databind ();

}

One note for this method: (when calling the method) This . Bindsqlpager2 ( This . Sqlpager1, ljhsqlpager2.sortmode. DESC, This . Getorderfield (), " Listid " , This . Getdbconnecstring (), " Dgcomments " , SQL, " ( " + SQL + " ) " , " * " , " Listid> 0 " );

The SQL here is the tablename parameter in the above method. Sometimes our SQL statements are complicated, so the table may be a complicated SQL statement. If it is just a table query, you can write the table name!

I will not talk about anything else. If you have any questions, leave a message or contact me! I am surfing the internet at night. During the day, the company prohibits Internet access!

Source code (Stored Procedure): sqlpager. rar
Sorry, the paging stored procedure in it is not the one I used in the control. I am sorry for the downloaded process.
Correct stored procedure: Paging Stored Procedure download

In response to the requirements of a large family, a small demo is provided, and the database is the northwind that comes with sqlserver.
: Demo download
Run the demo:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.