国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

大數量查詢分頁顯示 微軟的解決辦法

2024-05-04 11:01:49
字體:
來源:轉載
供稿:網友
微軟的解決辦法
using System; 
using System.Data; 
using System.Data.SqlClient; 
using System.Drawing; 
using System.Windows.Forms; 

public class PagingSample: Form 

// Form controls. 
Button prevBtn = new Button(); 
Button nextBtn = new Button(); 

static DataGrid myGrid = new DataGrid(); 
static Label pageLbl = new Label(); 

// Paging variables. 
static int pageSize = 10; // Size of viewed page. 
static int totalPages = 0; // Total pages. 
static int currentPage = 0; // Current page. 
static string firstVisibleCustomer = ""; // First customer on page to determine location for move previous. 
static string lastVisibleCustomer = ""; // Last customer on page to determine location for move next. 

// DataSet to bind to DataGrid. 
static DataTable custTable; 

// Initialize connection to database and DataAdapter. 
static SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind"); 
static SqlDataAdapter custDA = new SqlDataAdapter("", nwindConn); 
static SqlCommand selCmd = custDA.SelectCommand; 

public static void GetData(string direction) 

// Create SQL statement to return a page of records. 
selCmd.Parameters.Clear(); 

switch (direction) 

case "Next": 
selCmd.CommandText = "SELECT TOP " + pageSize + " CustomerID, CompanyName FROM Customers " + 
"WHERE CustomerID > @CustomerId ORDER BY CustomerID"; 
selCmd.Parameters.Add("@CustomerId", SqlDbType.VarChar, 5).Value = lastVisibleCustomer; 
break; 
case "Previous": 
selCmd.CommandText = "SELECT TOP " + pageSize + " CustomerID, CompanyName FROM Customers " + 
"WHERE CustomerID < @CustomerId ORDER BY CustomerID DESC"; 
selCmd.Parameters.Add("@CustomerId", SqlDbType.VarChar, 5).Value = firstVisibleCustomer; 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 绥德县| 定结县| 林周县| 仲巴县| 新乡县| 罗田县| 深水埗区| 苗栗市| 尼勒克县| 深圳市| 襄城县| 保亭| 定襄县| 乐安县| 夏津县| 宁都县| 江都市| 依兰县| 信丰县| 科技| 信阳市| 法库县| 乌恰县| 建宁县| 贵德县| 定襄县| 山西省| 公安县| 英吉沙县| 张家口市| 贺州市| 岑溪市| 岚皋县| 堆龙德庆县| 应城市| 陆良县| 右玉县| 九江市| 兴业县| 阳春市| 大荔县|