I am using ODBC to connect to a Sybase database. The problem is that the connection does not close even after the region is completed, and I see about 200 connections open in the database when sp_who starts. I tried to enable the connection pool, but that does not help either.
using(var connection = GetOdbcConnection()) { connection.Open(); using (var cmd = new OdbcCommand(query, connection)) { var reader = cmd.ExecuteReader(); if (reader.Read()) { long textLen = reader.GetChars(0, 0, null, 0, 0); } reader.Close(); } }
The connection string used is value="Driver={Adaptive Server Enterprise};app=xxx;server=xxxx;port=xxxx; db=xxx;uid=xxx;pwd=xxxx;textsize=2097152" .
Update:
public static OdbcConnection GetOdbcConnection() { string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString(); return new OdbcConnection(connectionString); }
source share