Server Error in '/' Application.

The connection was not closed. The connection's current state is open.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The connection was not closed. The connection's current state is open.

Source Error:


Line 380:            int ilk = 0;
Line 381:            baglan.Close();
Line 382:            baglan.Open();
Line 383:            SqlCommand emir = new SqlCommand(sql, baglan);
Line 384:            SqlDataReader dr = emir.ExecuteReader();

Source File: c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\App_Code\MyCode.cs    Line: 382

Stack Trace:


[InvalidOperationException: The connection was not closed. The connection's current state is open.]
   System.Data.ProviderBase.DbConnectionBusy.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +20
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +92
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +219
   System.Data.SqlClient.SqlConnection.Open() +101
   DataBase.doldur_DT(DataTable dt, String sql) in c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\App_Code\MyCode.cs:382
   urun_detay.gvkatbind() in c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\urun-detay.aspx.cs:119
   urun_detay.Page_Load(Object sender, EventArgs e) in c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\urun-detay.aspx.cs:31
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0