Server Error in '/' Application.

Invalid attempt to call MetaData when reader is closed.

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: Invalid attempt to call MetaData when reader is closed.

Source Error:


Line 393:                    for (int k1 = 0; k1 < j; k1++)
Line 394:                    {
Line 395:                        drow.Table.Columns.Add(dr.GetName(k1).ToString());
Line 396:                    }
Line 397:                    ilk = 1;

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

Stack Trace:


[InvalidOperationException: Invalid attempt to call MetaData when reader is closed.]
   System.Data.SqlClient.SqlDataReader.get_MetaData() +1794192
   System.Data.SqlClient.SqlDataReader.CheckMetaDataIsReady(Int32 columnIndex, Boolean permitAsync) +34
   System.Data.SqlClient.SqlDataReader.GetName(Int32 i) +20
   DataBase.doldur_DT(DataTable dt, String sql) in c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\App_Code\MyCode.cs:395
   ust.MenuUstkategoriDoldur4(String UstKategoriId) in c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\ust.ascx.cs:264
   ust.Page_Load(Object sender, EventArgs e) in c:\Inetpub\vhosts\korfezhalimobilya.com.tr\httpdocs\ust.ascx.cs:59
   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.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   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