I have a simple c# code in which I am trying to open and close connections multiple times. How can I ensure that my new connections are coming from connection pool and that it is not hitting the database?
using System;
using System.Data;
using System.Data.Odbc;
using System.Collections.Generic;
namespace LBSService
{
class MyClass {
public static OdbcConnection connection = null;
public void TestConnection()
{
string connectionstring = @"Dsn=my_database.IServer;Host=IServer;
Database=my_database;Uid=informix;
Pwd=Some@123";
for (int i = 1; i <= 50; i++)
{
string StrQuery = "select * from capture_files";
connection = new OdbcConnection(connectionstring);
connection.Open();
connection.Close();
}
}
}
}
I have limitation that I have to open an ODBC connection so answer related to ODBC is preferred.
Is there any data memeber within my 'connection' object or something where I can actually see how many unused connections are there in pool and how many are used by my application.
Thanks in advance...