微软的解决办法
USINGSYSTEM;
usingsystem.data;
usingsystem.data.sqlclient;
usingsystem.drawing;
usingsystem.windows.forms;
publicclasspagingasemple: форма
{
// FormControls.
Buttonprevbtn = newbutton ();
Buttonnextbtn = newbutton ();
staticdatagridmygrid = newdatagrid ();
staticLabelPageLbl = newLabel ();
// pagingvariables.
staticIntPagesize = 10; // sizeOfViewedPage.
staticintTotalPages = 0; // TotalPages.
staticintCurrentPage = 0; // CurrentPage.
stateCtringFirstVisibleCustomer =; // FirstCustomeronPageTodeterMineLocationFormovePrevious.
stateCtringLastVisibleCustomer =; // LastCustomeronPageTodeterMineLocationFormOvenext.
// DataSettoBindtoDatagrid.
staticDataTableCusttable;
// initializeconnectiontodatabaseanddataadapter.
statsicqlConnectionnWindConn = newsqlConnection (dataSource = localHost; IntegratedSecurity = SSPI; initialCatalog = NorthWind);
statsicqldataadaptercustda = newsqldataadapter (, nwindconn);
statsicqlcommandselcmd = custda.selectcommand;
publicstaticvoidgetData (StringDirection)
{
// createSqlStateMentTorurnApageOfRecords.
selcmd.parameters.clear ();
переключение (направление)
{
casenext:
selcmd.commandtext = selectTop+pagesize+customerId, companyNameFromCustomers+
Checustomerid> @customeridorderbycustomerid;
selcmd.parameters.add (@customerid, sqldbtype.varchar, 5) .value = lastvisiblecustomer;
перерыв;
казиновидный:
selcmd.commandtext = selectTop+pagesize+customerId, companyNameFromCustomers+
Wherecustomerid <@customeridorderbycustomeriddesc;
selcmd.parameters.add (@customerid, sqldbtype.varchar, 5) .value = firstvisiblecustomer;