|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP一般认为只能运行在IIS上,正如前面所提到的,这并不是十分正确,事实上,ASP也能运行在Apache上。ApacheASP可在任意Apache服务器上运行有限的ASP功能,所需做的,只需打开mod_perl。分页|办理|微软|显现|分页|微软微软的办理举措
usingSystem;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Drawing;
usingSystem.Windows.Forms;
publicclassPagingSample:Form
{
//Formcontrols.
ButtonprevBtn=newButton();
ButtonnextBtn=newButton();
staticDataGridmyGrid=newDataGrid();
staticLabelpageLbl=newLabel();
//Pagingvariables.
staticintpageSize=10;//Sizeofviewedpage.
staticinttotalPages=0;//Totalpages.
staticintcurrentPage=0;//Currentpage.
staticstringfirstVisibleCustomer="";//Firstcustomeronpagetodeterminelocationformoveprevious.
staticstringlastVisibleCustomer="";//Lastcustomeronpagetodeterminelocationformovenext.
//DataSettobindtoDataGrid.
staticDataTablecustTable;
//InitializeconnectiontodatabaseandDataAdapter.
staticSqlConnectionnwindConn=newSqlConnection("DataSource=localhost;IntegratedSecurity=SSPI;InitialCatalog=northwind");
staticSqlDataAdaptercustDA=newSqlDataAdapter("",nwindConn);
staticSqlCommandselCmd=custDA.SelectCommand;
publicstaticvoidGetData(stringdirection)
{
//CreateSQLstatementtoreturnapageofrecords.
selCmd.Parameters.Clear();
switch(direction)
{
case"Next":
selCmd.CommandText="SELECTTOP"+pageSize+"CustomerID,CompanyNameFROMCustomers"+
"WHERECustomerID>@CustomerIdORDERBYCustomerID";
selCmd.Parameters.Add("@CustomerId",SqlDbType.VarChar,5).Value=lastVisibleCustomer;
break;
case"Previous":
selCmd.CommandText="SELECTTOP"+pageSize+"CustomerID,CompanyNameFROMCustomers"+
"WHERECustomerID<@CustomerIdORDERBYCustomerIDDESC";
selCmd.Parameters.Add("@CustomerId",SqlDbType.VarChar,5).Value=firstVisibleCustomer;
break;
default:
selCmd.CommandText="SELECTTOP"+pageSize+"CustomerID,CompanyNameFROMCustomersORDERBYCustomerID";
//Determinetotalpages.
SqlCommandtotCMD=newSqlCommand("SELECTCount(*)FROMCustomers",nwindConn);
nwindConn.Open();
inttotalRecords=(int)totCMD.ExecuteScalar();
nwindConn.Close();
totalPages=(int)Math.Ceiling((double)totalRecords/pageSize);
break;
}
//Fillatemporarytablewithqueryresults.
DataTabletmpTable=newDataTable("Customers");
intrecordsAffected=custDA.Fill(tmpTable);
//Iftabledoesnotexist,createit.
if(custTable==null)
custTable=tmpTable.Clone();
//Refreshtableifatleastonerecordreturned.
if(recordsAffected>0)
{
switch(direction)
{
case"Next":
currentPage++;
break;
case"Previous":
currentPage--;
break;
default:
currentPage=1;
break;
}
pageLbl.Text="Page"+currentPage+"of"+totalPages;
//Clearrowsandaddnewresults.
custTable.Rows.Clear();
foreach(DataRowmyRowintmpTable.Rows)
custTable.ImportRow(myRow);
//Preservefirstandlastprimarykeyvalues.
DataRow[]ordRows=custTable.Select("","CustomerIDASC");
firstVisibleCustomer=ordRows[0][0].ToString();
lastVisibleCustomer=ordRows[custTable.Rows.Count-1][0].ToString();
}
}
publicPagingSample()
{
//Initializecontrolsandaddtoform.
this.ClientSize=newSize(360,274);
this.Text="NorthWindData";
myGrid.Location=newPoint(10,10);
myGrid.Size=newSize(340,220);
myGrid.AllowSorting=true;
myGrid.CaptionText="NorthWindCustomers";
myGrid.ReadOnly=true;
myGrid.AllowNavigation=false;
myGrid.PreferredColumnWidth=150;
prevBtn.Text="<<";
prevBtn.Size=newSize(48,24);
prevBtn.Location=newPoint(92,240);
prevBtn.Click+=newEventHandler(Prev_OnClick);
nextBtn.Text=">>";
nextBtn.Size=newSize(48,24);
nextBtn.Location=newPoint(160,240);
pageLbl.Text="NoRecordsReturned.";
pageLbl.Size=newSize(130,16);
pageLbl.Location=newPoint(</p>因为现在数据库都使用标准的SQL语言对数据库进行管理,所以如果是标准SQL语言,两者基本上都可以通用的。SQLServer还有更多的扩展,可以用存储过程,数据库大小无极限限制。 |
|