I'm developing a project using asp.net c# webforms framework 4.5, and I did a connection test on Firebird database, but when I close this connection it isn't closing, I used the following code to do it:
string conDDNS;
FbConnection conexaoDDNS;
protected void Abrir_Fechar_Click(object sender, EventArgs e)
{
try
{
this.conDDNS = "DRIVER=InterBase/Firebird(r) driver;User=SYSDBA;Password=masterkey;Database=localhost:C:/AdCom/ADCOM.FDB";
this.conexaoDDNS = new FbConnection(conDDNS);
this.conexaoDDNS.Open();
ListItem item = new ListItem("Conexão aberta");
ListBox1.Items.Add(item);
this.conexaoDDNS.Dispose();
this.conexaoDDNS.Close();
ListItem item2 = new ListItem("Conexão fechada");
ListBox1.Items.Add(item2);
}
catch (Exception erro)
{
ListItem item = new ListItem(erro.ToString());
ListBox1.Items.Add(item);
}
}
I have already used the .Close()
and .Dispose()
command but it didn't work.
When I did this debugging I realized that when it pass by .Open()
command it opens the connection, that is alright. But when it pass by .Close()
command the connection is still open on database.
To know the number of connections opened on database I'm using the following command:
select * FROM MON$ATTACHMENTS