網上看到的分頁語句

2021-05-22 23:27:09 字數 3188 閱讀 5428

具體不多說了,只貼出相關原始碼~

using system;

using system.collections.generic;

using system.text;

using system.data;

using system.data.oledb;

using system.web;

///

public class adopager

public adopager(string dbpath)

m_conn = new oledbconnection(m_connstring);

}/**

/// 開啟連線

///

public void connopen()

/**

/// 關閉連線

///

public void connclose()

private string recordid(string query, int passcount)

passcount--;}}

return result.substring(1);

}/**

/// 獲取當前頁應該顯示的記錄,注意:查詢中必須包含名為id的自動編號列,若不符合你的要求,就修改一下原始碼吧 :)

///

/// 當前頁碼

/// 分頁容量

/// 顯示的字段

/// 查詢字串,支援聯合查詢

/// 查詢條件,若有條件限制則必須以where 開頭

/// 排序規則

/// 傳出引數:總頁數統計

/// 傳出引數:總記錄統計

/// 裝載記錄的datatable

public datatable executepager(int pageindex, int pagesize, string showstring, string querystring, string wherestring, string orderstring, out int pagecount, out int recordcount)

) tempvw ", querystring);

oledbcommand cmdcount = new oledbcommand(string.format(" select count(0) as recordcount from ", myvw, wherestring), m_conn);

recordcount = convert.toint32(cmdcount.executescalar());

if ((recordcount % pagesize) > 0)

pagecount = recordcount / pagesize + 1;

else

pagecount = recordcount / pagesize;

oledbcommand cmdrecord;

if (pageindex == 1)//第一頁

from order by ", pagesize, showstring, myvw, wherestring, orderstring), m_conn);

}else if (pageindex > pagecount)//超出總頁數

from order by ", pagesize, showstring, myvw, "where 1=2", orderstring), m_conn);

}else

from order by ", pagelowerbound, "id", myvw, wherestring, orderstring), pageupperbound);

cmdrecord = new oledbcommand(string.format("select from where id in () order by ", showstring, myvw, recordids, orderstring), m_conn);

}oledbdataadapter dataadapter = new oledbdataadapter(cmdrecord);

datatable dt=new datatable();

dataadapter.fill(dt);

connclose();

return dt;}}

還有呼叫示例:html**

示例的codebehind**

using system;

using system.data;

using system.configuration;

using system.web;

using system.web.security;

using system.web.ui;

using system.web.ui.webcontrols;

using system.web.ui.webcontrols.webparts;

using system.web.ui.htmlcontrols;

using system.collections.generic;

public partial class _default : system.web.ui.page

}protected void page_load(object sender, eventargs e)

private int pageindex = 1;

private int pagesize = 20;

private int pagecount = -1;

private int recordcount = -1;

private void loaddata()

條記錄,每頁條,頁次/",recordcount,pagesize,pageindex,pagecount);

}protected void btnjump_click(object sender, eventargs e)

}

網上看到的 ResultSet更新彙總

可更新的結果集 更新一行 update cancelrowupdates updaterow rowupdated upadate 方法只能修改當前行的資料,並不能修改資料庫中的資料,所以在呼叫 update 後,還要呼叫 updaterow 方法,用當前行中的新資料更新資料庫。cancelrowu...

SQL匯入的方法,網上看到的

這是乙個新錶,準備用來匯入的表 create table csvtable name nvarchar max email nvarchar max area nvarchar max 從d csv.txt往裡插入資料,每個資料分割符是 每條資料的分隔符是 查詢你匯入的內容 曾經有人還給我說過另一種...

網上看到的,值得看一看

1.記住,平均每天看電視超過三個小時以上的,一定都是那些月收入不超過兩千元的。如果你想要月收入超過兩千,請不要把時間浪費在電視上。同樣的道理,那些平均每天玩網路遊戲或聊天超過三個小時以上的,也都是那些月收入不超過兩千的。不要說沒有時間學習,晚飯後到睡覺前是學習的時間。2.因為窮人很多,並且窮人沒有錢...