微软的解决办法
Sistem Using;
Usingsystem.data;
Usingsystem.data.sqlClient;
Usingsystem.drawing;
Usingsystem.windows.forms;
PublicClassPagings Contoh: Formulir
{
// FormControls.
TombolPrevBTN = newButton ();
ButtonNextBTN = newButton ();
staticdatagridmygrid = newDatagrid ();
staticlabelpagelbl = newLabel ();
// pagingvariable.
staticIntPagesize = 10; // sizeOfViewedPage.
STATICIntTotalPages = 0; // TotalPages.
StaticIntCurrentPage = 0; // currentpage.
staticstringfirstvisiblecustomer =; // firstcustomeronpagetodeterminelocionalCrevevious.
StaticStringLastVisiBlecustomer =; // lastcustomeronpagetodeterminelocationFeVenext.
// Datasettobindtodatagrid.
staticDataTableCustTable;
// initializeConnectionTodataBaseAndDataAdapter.
staticsqlConnectionNwindConn = newsqlConnection (DataSource = localhost; integratedsecurity = sspi; initialcatalog = Northwind);
staticsqldataadaptercustda = newsqldataadapter (, nwindconn);
staticsqlCommandselcmd = custda.selectCommand;
PublicstaticVoidGetData (StringDirection)
{
// createsqlstatementToReturnapageFrecords.
selcmd.parameters.clear ();
Switch (arah)
{
Casenext:
selcmd.CommandText = SelectTop+Pagesize+customerId, companynamefromcustomers+
WhereCustomerId> @customeridorderByCustomerId;
selcmd.parameters.add (@customerid, sqldbtype.varchar, 5) .value = lastvisiblecustomer;
merusak;
Caseprevious:
selcmd.CommandText = SelectTop+Pagesize+customerId, companynamefromcustomers+
WhereCustomerId <@customeridorderByCustomeriddesc;
selcmd.parameters.add (@customerid, sqldbtype.varchar, 5) .value = firstVisiblecustomer;