微软的解决办法
usingSystem;
usingSystem.data;
usingsystem.data.sqlclient;
usingSystem.Drawing;
usingsystem.windows.forms;
publicClassPagingsample: Formulaire
{
// Formontrols.
ButtonPrevbtn = newbutton ();
ButtonNextBtn = newButton ();
staticdatagridmygrid = newdatagrid ();
staticLabelPagelbl = newLabel ();
// PAGINGVARIBLES.
StaticIntPageSize = 10; // sizeofViewedPage.
statintTotalPages = 0; // TotalPages.
StaticIntCurrentPage = 0; // CurrentPage.
StateStringFiRStVisibleCustomer =; // FirstCustomeronPageTodeTerMineLocationFormovePrevious.
StateStRingLastVisibleCustomer =; // LastCustomerOnPageTodeTerMineLocationFormoVeNExt.
// DataSettObindTodatagrid.
staticDatatableCustTable;
// InitizizeConnectionTodatabaseAndDataAdapter.
statistiqueqlConnectionnwindConn = newsQlConnection (dataSource = localHost; intégréesecurity = sspi; initialCatalog = northwind);
statistiqueqldataadapterCustda = newsQLDataAdapter (, nwindConn);
statistiqueqlcommandSelcmd = custda.selectCommand;
publicStaticVoidGetData (StringDirection)
{
// créeqlstalementToreTurnapageOfRecords.
selcmd.parameters.clear ();
commutateur (direction)
{
Casenext:
selcmd.commandText = selecttop + pagesize + CustomerId, companyNameFromCustomers +
WhiCustomerId> @CustomerIdOrderByCustomerId;
selcmd.parameters.add (@ clientId, sqldbtype.varchar, 5) .value = lastVisibleCustomer;
casser;
caseprevious:
selcmd.commandText = selecttop + pagesize + CustomerId, companyNameFromCustomers +
WhiCustomerId <@CustomerIdOrderByCustomerIdDesc;
selcmd.parameters.add (@ clientId, sqldbtype.varchar, 5) .value = firstVisibleCustomer;