Rows is the number of rows sent by the client, page is the page number, the argument needs to be two parameters on the line, the SQL statement _row and _page self-declared local variables, the value or the corresponding row and page, in order to operate.
Use the database class to get its DataTable, converted to JSON format through the general processing program to the client, the client display is OK. Here I am using the Easyui DataGrid for receiving and transmitting parameters. This is the general idea.
String sql = "SELECT top" + Rows + "* from TestData where TestID not in (select Top" + (_rows * (_page-1)) + "TestID From TestData ORDER BY TestID Desc) Order BY testid Desc ";
//datatable converted to JSON, here with "Total", the number of data passed to the client, do not pass this, the client will not show the total data is how many bars.
Public Static stringCreatejsonparameters (DataTable DT,BOOLDisplaycount,inttotalcount) {StringBuilder jsonstring=NewStringBuilder (); //Exception Handling if(dt! =NULL) {jsonstring.append ("{ "); if(Displaycount) {jsonstring.append ("\ "Total\":"); Jsonstring.append (TotalCount); Jsonstring.append (","); } jsonstring.append ("\ "Rows\": ["); for(inti =0; i < dt. Rows.Count; i++) {jsonstring.append ("{ "); for(intj =0; J < dt. Columns.count; J + +) { if(J < dt. Columns.count-1) { //if (dt. ROWS[I][J] = = DBNull.Value) continue; if(dt. COLUMNS[J]. DataType = =typeof(BOOL) {jsonstring.append ("\""+ dt. COLUMNS[J]. ColumnName +"\":"+dt. ROWS[I][J]. ToString (). ToLower ()+","); } Else if(dt. COLUMNS[J]. DataType = =typeof(string) {jsonstring.append ("\""+ dt. COLUMNS[J]. ColumnName +"\":"+"\""+dt. ROWS[I][J]. ToString (). Replace ("\"","\\\"") +"\","); } Else{jsonstring.append ("\""+ dt. COLUMNS[J]. ColumnName +"\":"+"\""+ dt. ROWS[I][J] +"\","); } } Else if(j = = dt. Columns.count-1) { //if (dt. ROWS[I][J] = = DBNull.Value) continue; if(dt. COLUMNS[J]. DataType = =typeof(BOOL) {jsonstring.append ("\""+ dt. COLUMNS[J]. ColumnName +"\":"+dt. ROWS[I][J]. ToString ()); } Else if(dt. COLUMNS[J]. DataType = =typeof(string) {jsonstring.append ("\""+ dt. COLUMNS[J]. ColumnName +"\":"+"\""+dt. ROWS[I][J]. ToString (). Replace ("\"","\\\"") +"\""); } Else{jsonstring.append ("\""+ dt. COLUMNS[J]. columnname+"\":"+"\""+ dt. ROWS[I][J] +"\""); } } } /*End of String*/ if(i = = dt. Rows.Count-1) {jsonstring.append ("} "); } Else{jsonstring.append ("}, "); }} jsonstring.append ("]"); Jsonstring.append ("}"); returnJsonstring.tostring (). Replace ("\ n",""); } Else { return NULL; } }
NET one sentence to take care of pagination