How to disconnect database in asp.net
Hi There;
I have a asp.net project. My aim is to connect postgres database, perform some actions and disconnect from database. The connection is being set up while the page loads, and it is expected to disconnect it from database by clicking a button. But it doesn't. Here are my codes. To clarify, codes have been purified. My aspx side: Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="select_data_2.aspx.cs" Inherits="_08_Veritabanlari_AD0_NET_select_data_2" %> Code:
using System; add1: I have defined the private NpgsqlConnection conn and private NpgsqlCommand command variables as static, but no disconnection again. |
You don't show all your relevant code, or show why you think it's not disconnecting, nor what happens when you try to do so. The connectToDatabase routine is not shown. You should set this.conn = null in a finally block so that it happens even if the disconnect attempt fails. You need to be certain you know what this is, and you also need to be certain that this.conn does in fact contain a valid connection-handle. If it is null then you should see an exception to that effect being thrown.
However ... this really isn't the right place to be asking for programmers to "debug my code for me." You should be asking your manager or co-workers, and you should have done so long before now. Someone fifteen meters away from you in Turkey could probably have solved your problem in minutes and the project would not be delayed. |
Almost every user of this forum struggle for solving their programming problems.Apart from the fact of impreciseness of being very sure of not performing a debug over the code, when I take a look at the forums topic, many problems could be solved by debugging. If I have a chance to ask someone fifteen meters away from me in Turkey, I will not attemp to steal your precios time.
Here are my whole code: Code:
using System; Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="select_data_2.aspx.cs" Inherits="_08_Veritabanlari_AD0_NET_select_data_2" %> |
All times are GMT -5. The time now is 08:47 AM. |