我正在使用asp.net c#webforms framework 4.5开发一个项目,并且我在Firebird数据库上进行了连接测试,但当我关闭此连接时它没有关闭,我使用以下代码来执行此操作:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
我已经使用了.Close()和.Dispose()命令,但它没有用.
当我进行这个调试时,我意识到当它通过.Open()命令传递时它会打开连接,这没关系.但是当它通过.Close()命令时,连接仍然在数据库上打开.
要知道在数据库上打开的连接数,我使用以下命令:
select * FROM MON$ATTACHMENTS
Run Code Online (Sandbox Code Playgroud)