微软的解决办法
Usingsystem;
Usingsystem.data;
Usingsystem.data.sqlclient;
Usingsystem.drawing;
Usingsystem.windows.forms;
publicClasspagingsample: formulário
{
// formcontrols.
ButtonPrevBtn = newButton ();
ButtonNextBtn = newButton ();
staticDataGridMyGrid = newDataGrid ();
staticLabelPagelBl = newlabel ();
// PAGINGVARIABLES.
staticIntpagesize = 10; // sizeofviewedPage.
staticIntTotalPages = 0; // TotalPages.
staticIntCurrentPage = 0; // CurrentPage.
STATICSTRINGFIRSTVISIBLECUSTOMER =; // FIRSTCUSTOMERONPAGETODETERMINELOCATIONformOvePrevious.
STATICSTRINGLASTVISIBLECUSTOMER =; // LASTCUSTOMERONPAGETODETERMINELOCATIONFORMOVENEXT.
// DataSetTObindTodataGrid.
staticDatatableCusttable;
// InitializeConnectionTodatabaseAnddataAdapter.
STATICSQLCONNECTIONNWindCONN = NewsQLConnection (DataSource = localhost; integratedSecurity = sspi; InitialCatalog = Northwind);
STATICSQLDATAADAPTERCUSTDA = NewsqldataAdapter (, Nwindconn);
STATICSQLCommandselCmd = CustDA.SelectCommand;
publicstaticVoidGetData (StringDirection)
{
// CreateSqlStatementTeTurnApageOfRecords.
selcmd.parameters.clear ();
Switch (direção)
{
Casenext:
Selcmd.CommandText = SelectTop+Pagesize+CustomerId, CompanyNameFromCustomers+
Wherecustomerid> @customeridorderbycustomerid;
Selcmd.parameters.add (@CustomerID, sqldbtype.varchar, 5) .Value = lastVisIbleCustomer;
quebrar;
Casevious:
Selcmd.CommandText = SelectTop+Pagesize+CustomerId, CompanyNameFromCustomers+
Wherecustomerid <@customeridorderbycustomeriddesc;
Selcmd.parameters.add (@CustomerID, sqldbtype.varchar, 5) .Value = FirstVisIbleCustomer;