Server Error in '/' Application.

Index and length must refer to a location within the string.
Parameter name: length

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.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length

Source Error:


Line 884:        if (firstName != "") Name += " " + firstName; 
Line 885:        if (initials  != "") Name += " " + initials; 
Line 886:        Initial = Name.Substring(0,1).ToUpper();
Line 887:		
Line 888:		Affiliation = (string) reader["Affiliation"];

Source File: d:\uaps2019\app_code\pampaClasses.cs    Line: 886

Stack Trace:


[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
   System.String.Substring(Int32 startIndex, Int32 length) +14689712
   Participant..ctor(SqlDataReader reader) in d:\uaps2019\app_code\pampaClasses.cs:886
   PampaDataContext.GetParticipantsWhere(String where, Boolean final) in d:\uaps2019\app_code\dataContext.cs:1224
   PampaDataContext.GetParticipants(Boolean final) in d:\uaps2019\app_code\dataContext.cs:1198
   ASP._Page__participants_cshtml.Execute() in d:\uaps2019\_participants.cshtml:7
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +99
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +182
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122
   System.Web.WebPages.<>c__DisplayClass40_0.<RenderPageCore>b__0(TextWriter writer) +309
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +108
   ASP._Page_participants_cshtml.Execute() in d:\uaps2019\participants.cshtml:7
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +99
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +182
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +142


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