微软的解决办法
使用系统;
usingsystem.data;
usingsystem.data.sqlclient;
usingsystem.drawing;
Usingsystem.windows.forms;
uplyClassPagingsample:表格
{
// formcontrols。
buttonprevbtn = newbutton();
buttonnextbtn = newbutton();
staticdatagridmygrid = newdatagrid();
staticlabelpagelbl = newlabel();
// pagingvariables。
staticintpagesize = 10; // sizeofviewedpage。
staticinttotalpages = 0; // TotalPages。
staticintCurrentPage = 0; // CurrentPage。
staticstringfirstvisiblecustomer =; // first customeronpagetodeTermineLocationformovePrevious。
staticstringlastvisiblecustomer =; // lastcustomeronpagetodeTerminElocationformovenext。
// datasettobindtodatagrid。
静态databablecusttable;
// initizeconnectiontodatabaseanddataadapter。
staticsqlConnectionNwindConn = newsqlConnection(dataSource = localhost; IntegratedSecurity = sspi; onitionCatalog = northwind);
staticsqldataAdapterCustda = newsqldataAdapter(,nwindconn);
staticsqlcommandselcmd = custda.SelectCommand;
publicStaticVoidGetData(StringDirection)
{
//创建QLSTATEMENTTORETRETNAPAGEOFRECORDS。
selcmd.parameters.clear();
开关(方向)
{
casenext:
selcmd.commandText = selecttop+pagesize+customerId,companynameFromCustomers+
wherecustomerid> @customeridorderbycustomerid;
selcmd.parameters.add(@customerId,sqldbtype.varchar,5).value = lastVisibleCustomer;
休息;
Caseprevious:
selcmd.commandText = selecttop+pagesize+customerId,companynameFromCustomers+
wherecustomerid <@customeridordorderbycustomeriddesc;
selcmd.parameters.add(@customerId,sqldbtype.varchar,5).value = firstVisibleCustomer;