国产探花免费观看_亚洲丰满少妇自慰呻吟_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; 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武乡县| 台南市| 广水市| 防城港市| 东明县| 谢通门县| 宁南县| 沛县| 延寿县| 安丘市| 万盛区| 云南省| 秀山| 潢川县| 鄂托克前旗| 汕尾市| 蓝山县| 辉南县| 德保县| 昌江| 东乌珠穆沁旗| 襄汾县| 舟山市| 连州市| 井陉县| 化隆| 江华| 富宁县| 榆林市| 探索| 开原市| 永昌县| 胶南市| 垣曲县| 克拉玛依市| 甘肃省| 华池县| 甘肃省| 靖西县| 靖安县| 济源市|