我觉得没有必要用一个类来特别处理Connection是否处理关闭或打开状态并对其加以控制吧。数据库本身可以提供连接池的管理。我们的程序中只需要简单地建立一个连接,用完后关闭该连接就可以了。

解决方案 »

  1.   

    do not return DataReader in Remoting, use DataSet or DataTable and close the connection before you return DataSet or DataTable
      

  2.   

    spring_ok(spring.z):
    数据库连接需要显示的关闭后才能自动的放入到连接池中啊
    那“超出最大进程数“怎麽解释呢?我明明关闭连接了啊??这怎麽解决呢??如果这样的话,我的程序中的timer只能运行10次左右系统就当掉了啊,这样没法用啊~~~~
      

  3.   

    to saucer(思归):
        我上面的代码返回的是一个数组呀,我的reader和connection在远程对象中就已经关闭了啊,怎麽也不行了,我非常不理解~~~~:(
        如果我返回Dataset,那远程对象中的Dataset对象又在什麽地方、怎样Clear呢?
      

  4.   

    sorry, I did not pay attentionI start to think there is a configuration problem with Oracle
      

  5.   

    to saucer(思归) :
    为什麽如下方式就没有为题呢?我在Command类中建了下面一个方法
    public static OleDbConnection testConn(string userId,string password,string serviceName)
    {
    string connectionString=null;
    connectionString="Provider=MSDAORA;Data Source=" + serviceName + ";User ID=" + userId + ";Password=" + password; Provider myProvider=new Provider();
    System.Data.OleDb.OleDbConnection conn=null;
    try
    {
    conn=myProvider.getConnOleDb(connectionString);
    conn.Open();
    return conn;
    }
    catch
    {
    conn=null;
    return conn;
    throw new Exception("发生错误");
    }
    finally
    {
    conn.Close();
    }
    }
    在远程对象cs中
    调用上述方法
    public OleDbConnection myConn(string userId,string password,string serviceName)
    {
    return Command.testConn(userId,password,serviceName);
    }
    然后在客户端调用myConn,调用多少次也不会出错,这是为什麽呢?跟我出错的那个有什麽实质性的区别吗???
    请指教?
    如果是Oracle数据库配置出错那能出什麽错误呢?我就是默认安装的啊???
      

  6.   

    我也遇到类似的问题,现在也无法解决。命真苦啊!请大家关照。http://www.csdn.net/expert/topic/1029/1029444.xml?temp=.3247187
      

  7.   

    finally
    {
    conn.Close();
    }
    hehe, :-)sorry, I am not so sure about how Oracle handles connection pooling now. Here is what you can do, although it could affect the performance badly,try
    {
    //.....
      reader.Close();
      reader=null;
    }
    catch(Exception ep)
    {
    ....
    }
    finally
    {
       OleDbConnectionClose();
       oleDbConn = null;
       GC.Collect();
    }You might want to try Microsoft .NET Framework Data Provider for Oracle 
    http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/940/msdncompositedoc.xmlor Oracle Data Provider for .NET
    http://otn.oracle.com/tech/windows/content.html