微软的解决办法
usingsystem;
usingsystem.data;
usingsystem.data.sqlclient;
usingsystem.drawing;
usingsystem.windows.forms;
PublicClassPagingSample: Forma
{
// FormControls.
ButtonPrevBtn = newButton ();
ButtonNextBtn = newButton ();
staticDataGridMyGrid = newDataGrid ();
staticLabelpagelbl = newLabel ();
// Paging Variables.
staticIntPagesize = 10; // sizeOfViewedPage.
staticinttotalpages = 0; // totalpages.
staticIntCurrentPage = 0; // CurrentPage.
STATICSTRINGFIRSTVISIBLECUSTOMER =; // FirstCustomeronpageTodeterminelocationFormovePrevious.
STATICSTRINGLASTVISIBLECUSTOMER =; // LastCustomeronpageTodeterminElocationFormovExt.
// DataSettobindTodataGrid.
staticDatatableCusttable;
// InitializeConnectionTodatabaseAndDataAdapter.
staticsqlconnectionnwindconn = newsqlconnection (dataSource = localhost; integradoSecurity = sspi; inicialCatalog = northwind);
staticsqldataAdapterCustda = newsQlDataAdapter (, nwindconn);
STATICSQLCOMMANDSELCMD = custda.selectCommand;
PublicStaticVoidGetData (StringDirection)
{
// CreateSqlStatementToreturnApageOfRecords.
selcmd.parameters.clear ();
interruptor (dirección)
{
Casenext:
selcmd.commandText = selectTop+PageSize+CustomerId, CompanyNameFromCustomers+
WhereCustomerID> @CustomerIdorderByCustomerID;
selcmd.parameters.add (@customerID, sqldbtype.varchar, 5) .value = lastVisIbleCustomer;
romper;
Caseprevioso:
selcmd.commandText = selectTop+PageSize+CustomerId, CompanyNameFromCustomers+
WhereCustomerId <@CustomerIdorderByCustomerIdDesc;
selcmd.parameters.add (@customerID, sqldbtype.varchar, 5) .value = firstVisIBlecustomer;