惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MyScale Blog
MyScale Blog
U
Unit 42
M
MIT News - Artificial intelligence
小众软件
小众软件
P
Proofpoint News Feed
雷峰网
雷峰网
L
LangChain Blog
S
SegmentFault 最新的问题
腾讯CDC
F
Fortinet All Blogs
A
About on SuperTechFans
WordPress大学
WordPress大学
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
Recent Announcements
Recent Announcements
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog

博客园 - 天生舞男

多个平均数列的子查询 迁移sharepoint Sharepoint迁移数据库之绝版(只要照着做,一定能够迁移成功) Sharepoint的webpart 虚函数和非虚函数的调用基本原则 The visio to drawing project chart. - 天生舞男 Using MSChart from a C# WinForm About the deeply copy 学习程序的自我建议---从实际软件的源代码开始学习 How to get response content with specified post data by post method Post method tip automation服务器不能创建对象 Get the biggest common divisor rose破解 ArrayList按Index删除的问题 Recently expection RadioButtonList中选择框和文字对不齐的解决办法 resolve problem best method is find document from official document 看了宝玉的作品,心理甚是感叹
MS bug "The connection pool" in Oracle 10g and the data s...
天生舞男 · 2006-03-15 · via 博客园 - 天生舞男

1.Issue:
    The program prepares three SQL sentences to execute, the operation is like:
    1. It is correct to executes the first SQL sentence. 
    2. before executes the second SQL sentence, we pull out the network line, and executes the second SQL sentence.
    3. before executes the third SQL sentence, plug the network line, and executes the third SQL sentence.
    result:   
    The third SQL sentence can't execute correctly
2.Causation:
    The issue occurs by connection pool, the defualt value of "Connection Lifetime" is max timeout, so when we pull out the network line, and then plug it, the next OracleConnection object will using the previous OracleConnection object from connection pool, and the previous OracleConnection object is invalid, so the program leads to the issue.

3.How to resolve:
   The progrom had added the connection string with ";Pooling='true';Connection Lifetime=10".
   If over 10 seconds, the progrom will create a new OraleConnection object, but it is not the best solution for the 
   performance is inefficient, but if we setup the .Net Framework 1.1 SP1 cann't resolve the issue.

private void OpenConnection()
{
    oconDBCon = new OracleConnection(strDBConStr);
    oconDBCon.Open();
}

private void CloseConnection()
{
    if (null != oconDBCon)
    {
        if (ConnectionState.Open == oconDBCon.State)
        {
             oconDBCon.Close();
        }
        oconDBCon = null;
    }
}

public DataTable DPExecuteDataTable(string strSql)
{
    DataTable dtRet = new DataTable();
    OracleCommand ocomSql = null;
    OracleDataAdapter odaSql = new OracleDataAdapter();

    try
    {
        OpenConnection();
        ocomSql = oconDBCon.CreateCommand();
         ocomSql.CommandText = strSql;
         odaSql.SelectCommand = ocomSql;
         odaSql.Fill(dtRet);
    }
    catch (OracleException oex)
    {  
                CDPEventLog.ThrowException("MSGID_ERROR_DPEXECUTEDATATABLE_ORACLE_EXCEPTION",     strSql, oex);
     }
    finally
    {
         CloseConnection();
    }
    return dtRet;
}

The second program is for the data sort according to specified filed on DataGrid control when customming the fields
private void Page_Load(object sender, System.EventArgs e)
  {
   if(!Page.IsPostBack)
   {
    ViewState["strSortExpression"] = "";
   }
}
private void dgSort_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
  { 
   string strSortExpression = e.SortExpression;
   if (ViewState["strSortExpression"].ToString() == strSortExpression)
   {
    strSortExpression = strSortExpression.Replace("DESC", "ASC");
   }
   ViewState["strSortExpression"] = strSortExpression;
   dasEquipmentList.Tables[0].DefaultView.Sort = ViewState["strSortExpression"].ToString();
   dgSort.DataSource = dasEquipmentList.Tables[0].DefaultView;
   dgSort.DataBind();
  }