sql內(nèi)存溢出怎么解決
sql內(nèi)存溢出怎么解決?編程的時(shí)候或多或少會(huì)遇到這種問(wèn)題,那么解決方法是什么樣呢?下面是學(xué)習(xí)啦小編收集整理的一些相關(guān)的知識(shí),希望對(duì)大家有幫助!
sql內(nèi)存溢出怎么解決?
舉個(gè)栗子
一句簡(jiǎn)單SQL引發(fā)了內(nèi)存溢出
string sqlText = "SELECT T.* FROM fats T ";
OracleCommand cmd = new OracleCommand(sqlText);
pageDt=new DbUtility().Query(cmd);
DbUtility是一個(gè)數(shù)據(jù)庫(kù)幫助類,和大部分的沒(méi)什么區(qū)別
問(wèn)題是該頁(yè)面執(zhí)行別的的語(yǔ)句沒(méi)問(wèn)題
public partial class ShipMovingSearch : BasePage
{
protected DataTable pageDt;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitPage();
}
}
private void InitPage()
{
string SqlForDropType = "select * from fbtype t";
OracleCommand cmd = new OracleCommand(SqlForDropType);
this.DropShipType.DataSource = new DbUtility().Query(cmd);
this.DropShipType.DataTextField = "TYPE_NAME";
this.DropShipType.DataValueField = "TYPE_ID";
this.DropShipType.DataBind();
//BtnSearch_Click(this.BtnSearch, new EventArgs());
}
protected void BtnSearch_Click(object sender, EventArgs e)
{
string sqlText = "SELECT T.* FROM fats T ";
OracleCommand cmd = new OracleCommand(sqlText);
pageDt=new DbUtility().Query(cmd);
}
}
init里面的sql執(zhí)行就沒(méi)問(wèn)題
一到按鈕按下就出問(wèn)題
sql內(nèi)存溢出的解決方法
解決方案一:
select top 20 * from fats where sid not in (select top 40 sid from fats order by sid )
解決方案二:
升級(jí)到sql2012 分頁(yè) 容易
解決方案三:
分頁(yè)還是用存儲(chǔ)過(guò)程好些