I'm using the following function to connect to the database, I'm programming in C # in Visual Studio 2013.
namespace WindowsFormsApplication1
{
static class Conexao
{
private static String strConn = Properties.Settings.Default.caminhoFbConnection;
private static FbConnection conn = null;
public static void Conection()
{
}
public static FbConnection getConnection()
{
try
{
if (conn == null)
{
conn = new FbConnection(strConn);
conn.Open();
return conn;
}
else
{
if (conn.State == System.Data.ConnectionState.Open)
{
return conn;
}
else
{
conn.Open();
return conn;
}
}
}
catch (Exception excep)
{
MessageBox.Show("Erro - " + excep.Message);
return null;
}
}
public static void closeConnection()
{
try
{
conn.Close();
}
catch (Exception excep)
{
MessageBox.Show(excep.Message);
}
}
}
}
My idea of how to use this function would be, the connection only open, perform the necessary operations and then close the connection. But I have some problems.
When using this connection template Firebird connection pool will only have 1 active connection, or when I open the connection and close it the pool goes increasing?
I created in Firebird a sample table with auto increment of the primary key using trigger , but it is incrementing by 2 when I open and close the connection if I insert two items without closing the connection it increments by 1. What can cause this?