views:

222

answers:

2

When connecting to oracle server from .NET application using ADO.NET for oracle, even if i closed the connection, the connection remains inactive at the Oracle server, so new connections could not be established because of the sessions per user limitation, is there is any way to make sure that all connections are closed? from Oracle server or from .NET application.

Thanks in advance

+5  A: 

Could it be the connections stay open for a while due to connection pooling? Can you please paste some code showing how you close the connections? Also are you using ODP.NET or the Microsoft supplied classes?

You could try turning connection pooling off (add ;Pooling=false to the connection string in ODP.NET) to see if your issue is caused as a consequence of using it (just be aware that creating a new physical connection to the DB is an expensive operation, so you probably actually don't want to turn off connection pooling permantly).

RichardOD
Thanks,I turned pooling off but still got the same error, but i am using microsoft classes in .NET 3.5 (microsoft provider for oracle) is it a know issue for microsoft provider? or should i use ODP.NET?Regards.
Bashar Kokash
The ODP.NET client can do more than MS one and the MS one is being deprecated in .NET 4.0 so moving to ODP.NET is advisable. To further solve the issue though I recommend you paste some sample code.
RichardOD
A: 

Something similar to:

using (OracleConnection connection = new OracleConnection(connectionString))
{
    OracleCommand command = new OracleCommand(queryString);
    command.Connection = connection;
    try
    {
        connection.Open();
        command.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}
Bashar Kokash