locked
CRM trapping .NET error before I can catch it? RRS feed

  • Question

  • This is a fun one.

    I have written a custom search page that provides faster, more user friendly searches than the default Contacts view and also allows searching of Leads and Contacts simultaneously.  It uses GridViews bound to SqlDataSources that query filtered views.  I'm sure someone will complain that I'm not using the web services for this, but this is just the design decision we made. 

    These GridViews live in UpdatePanels to enable very slick AJAX updates upon search. 

    It's all working great. Nearly ready to be deployed, except for one thing:  Some long running searches are triggering an uncatchable SQL timeout exception. 

    [SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
      at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    
      at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    
      at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    
      at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    
      at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    
      at System.Data.SqlClient.SqlDataReader.get_MetaData()
    
      at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    
      at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    
      at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    
      at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    
      at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    
      at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    
      at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
    
      at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    
      at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    
      at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
    
      at System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
    
      at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
    
      at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
    
      at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
    
      at System.Web.UI.WebControls.GridView.DataBind()
    
      at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
    
      at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
    
      at System.Web.UI.Control.EnsureChildControls()
    
      at System.Web.UI.Control.PreRenderRecursiveInternal()
    
      at System.Web.UI.Control.PreRenderRecursiveInternal()
    
      at System.Web.UI.Control.PreRenderRecursiveInternal()
    
      at System.Web.UI.Control.PreRenderRecursiveInternal()
    
      at System.Web.UI.Control.PreRenderRecursiveInternal()
    
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    I found that CRM is doing a server.transfer to capture this error because my UpdatePanels started throwing JavaSript errors when this error would occur.  I was only able to get the full error message by using the JavaScript debugger in IE.

    Having found this error, I thought the solution would be simple.  I just needed to wrap my databind calls in try/catch blocks to capture any errors. 

    Unfortunately it seems CRM's IIS configuration has the magic ability to capture this error before it ever gets back to my code.  Using the debugger I never see it.  It never gets to my catch blocks, but it's clearly happening in the SQL Data Source which is clearly (by the stack trace) being triggered by my GridView bind. 

    Any ideas on this? It's driving me crazy.

    My code:

      protected void Page_Load(object sender, EventArgs e)
      {
        //Initialize some stuff
        this.bannerOracle = new OdbcConnection(ConfigurationManager.ConnectionStrings["OracleConnectionString"].ConnectionString);
    
        //Prospect default
        HideProspects();
        HideProspectAddressColumn();
    
        //Contacts default
        HideContactAddressColumn();
    
        //Default error messages
        gvContacts.EmptyDataText = "Sad day. Your search returned no contacts.";
        gvProspects.EmptyDataText = "Sad day. Your search returned no prospects.";
    
        //New search
        try
        {
          SearchContact(null, -1);
        }
        catch
        {
          gvContacts.EmptyDataText = "Oops! An error occured. This may have been a timeout. Please try your search again.";
          gvContacts.DataSource = null;
          gvContacts.DataBind();
        }
      }
      protected void txtSearchString_TextChanged(object sender, EventArgs e)
      {
        if(!String.IsNullOrEmpty(txtSearchString.Text))
        {
          try
          {
            SearchContact(txtSearchString.Text, Convert.ToInt16(lstSearchType.SelectedValue));
          }
          catch
          {
            gvContacts.EmptyDataText = "Oops! An error occured. This may have been a timeout. Please try your search again."; 
            gvContacts.DataSource = null;
            gvContacts.DataBind();
          }
    
          if (chkProspects.Checked == true)
          {
            try
            {
              SearchProspect(txtSearchString.Text, Convert.ToInt16(lstSearchType.SelectedValue));
            }
            catch
            {
              gvProspects.EmptyDataText = "Oops! An error occured. This may have been a timeout. Please try your search again.";
              gvProspects.DataSource = null;
              gvProspects.DataBind();
            }
            finally
            {
              ShowProspects();
            }
          }
          else
          {
            HideProspects();
          }
        }
      }
      protected void SearchContact(string search, int type)
      {
        SqlCRM_Contact.ConnectionString = ConfigurationManager.ConnectionStrings["MSSQLConnectionString"].ConnectionString;
        gvContacts.DataSourceID = "SqlCRM_Contact";
    
        string strQuery = "";
        string baseQuery = @"SELECT filteredcontact.contactid,
                     filteredcontact.new_libertyid,
                     filteredcontact.fullname,
                     'none' AS line1,
                     filteredcontact.emailaddress1,
                     filteredcontact.telephone1,
                     filteredcontact.birthdateutc AS birthdate,
                     filteredcontact.gendercodename
                  FROM filteredcontact "; 
        switch(type)
        {
          case LASTFIRST:
            strQuery = baseQuery + "WHERE fullname LIKE @value AND filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case LAST:
            strQuery = baseQuery + "WHERE lastname LIKE @value AND filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case FIRST:
            strQuery = baseQuery + "WHERE firstname LIKE @value AND filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case LIBERTYID:
            strQuery = baseQuery + "WHERE new_libertyid LIKE @value AND filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case EMAIL:
            strQuery = baseQuery + "WHERE emailaddress1 LIKE @value AND filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case TELEPHONE:
            strQuery = baseQuery + "WHERE telephone1 LIKE @value AND filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case BIRTHDAY:
            strQuery = baseQuery + "WHERE filteredcontact.birthdateutc BETWEEN @dateStart AND @dateEnd AND filteredcontact.statecode = 0";
            try
            {
              DateTime temp = DateTime.Parse(search);
              if (temp.Year < 1753 || temp.Year > 9999)
              {
                search = string.Empty;
              }
              else
              {
                search = temp.ToString("yyyy-MM-dd");
              }
            }
            catch
            {
              search = string.Empty;
            }
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("dateStart", DbType.String, search.Trim() + " 00:00:00.000");
            SqlCRM_Contact.SelectParameters.Add("dateEnd", DbType.String, search.Trim() + " 23:59:59.999");
            break;
          case SSN:
            //Do something
            break;
          case ADDRESS:
            strQuery = @"SELECT contactid,
    	              new_libertyid,
    	              fullname,
    	              line1,
    	              emailaddress1,
    	              telephone1,
    	              birthdate,
    	              gendercodename 
    	              FROM (SELECT FC.contactid,
    	                    FC.new_libertyid,
    	                    FC.fullname,
    	                    FA.line1,
    	                    FC.emailaddress1,
    	                    FC.telephone1,
    	                    FC.birthdateutc AS birthdate,
    	                    FC.gendercodename,
    	                    ROW_NUMBER() OVER(PARTITION BY FC.contactid ORDER BY FC.contactid DESC) AS rn 
    	                   FROM filteredcontact FC 
    	                   INNER JOIN FilteredCustomerAddress FA
    	                   ON FC.contactid = FA.parentid
    	                   WHERE FA.line1 LIKE @value AND FA.addressnumber <> 1 AND FC.statecode = 0 ) AS RESULTS
    	              WHERE rn = 1";
            SqlCRM_Contact.SelectCommand = strQuery;
            SqlCRM_Contact.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            ShowContactAddressColumn();
            break;
          default:
            strQuery = @"SELECT TOP 500 filteredcontact.contactid,
                     filteredcontact.new_libertyid,
                     filteredcontact.fullname,
                     'none' AS line1,
                     filteredcontact.emailaddress1,
                     filteredcontact.telephone1,
                     filteredcontact.birthdateutc AS birthdate,
                     filteredcontact.gendercodename
                  FROM filteredcontact 
                  WHERE filteredcontact.statecode = 0";
            SqlCRM_Contact.SelectCommand = strQuery;
            break;
        }
        if (type != ADDRESS)
        {
          HideContactAddressColumn();
        }
        gvContacts.PageIndex = 0;
        //try
        //{
        //  SqlCRM_Contact.DataBind();
        //}
        //catch
        //{
        //  SqlCRM_Contact.DataBind();
        //}
        gvContacts.DataBind();
      }
      protected void SearchProspect(string search, int type)
      {
        SqlCRM_Prospect.ConnectionString = ConfigurationManager.ConnectionStrings["MSSQLConnectionString"].ConnectionString;
        gvProspects.DataSourceID = "SqlCRM_Prospect";
    
        string strQuery = "";
        string baseQuery = @"SELECT filteredlead.leadid,
                     filteredlead.fullname,
                     'none' AS address1_line1,
                     filteredlead.emailaddress1,
                     filteredlead.telephone1,
                     filteredlead.lu_dateofbirthutc AS lu_dateofbirth,
                     filteredlead.lu_gendername
                  FROM filteredlead ";
    
        switch (type)
        {
          case LASTFIRST:
            strQuery = baseQuery + "WHERE fullname LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case LAST:
            strQuery = baseQuery + "WHERE lastname LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case FIRST:
            strQuery = baseQuery + "WHERE firstname LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case LIBERTYID:
            strQuery = baseQuery + "WHERE new_libertyid LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case EMAIL:
            strQuery = baseQuery + "WHERE emailaddress1 LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case TELEPHONE:
            strQuery = baseQuery + "WHERE telephone1 LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            break;
          case BIRTHDAY:
            strQuery = baseQuery + "WHERE filteredlead.lu_dateofbirth BETWEEN @dateStart AND @dateEnd AND filteredlead.statecode = 0";
            try
            {
              DateTime temp = DateTime.Parse(search);
              if (temp.Year < 1753 || temp.Year > 9999)
              {
                search = string.Empty;
              }
              else
              {
                search = temp.ToString("yyyy-MM-dd");
              }
            }
            catch
            {
              search = string.Empty;
            }
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("dateStart", DbType.String, search.Trim() + " 00:00:00.000");
            SqlCRM_Prospect.SelectParameters.Add("dateEnd", DbType.String, search.Trim() + " 23:59:59.999");
            break;
          case SSN:
            //Do nothing
            break;
          case ADDRESS:
            strQuery = @"SELECT filteredlead.leadid,
                     filteredlead.fullname,
                     filteredlead.address1_line1,
                     filteredlead.emailaddress1,
                     filteredlead.telephone1,
                     filteredlead.lu_dateofbirthutc AS lu_dateofbirth,
                     filteredlead.lu_gendername
                  FROM filteredlead WHERE address1_line1 LIKE @value AND filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            SqlCRM_Prospect.SelectParameters.Add("value", DbType.String, search.Trim() + "%");
            ShowProspectAddressColumn();
            break;
          default:
            strQuery = @"SELECT TOP 500 filteredlead.leadid,
                     filteredlead.fullname,
                     'none' AS address1_line1
                     filteredlead.emailaddress1,
                     filteredlead.telephone1,
                     filteredlead.lu_dateofbirthutc AS lu_dateofbirth,
                     filteredlead.lu_gendername
                  FROM filteredlead WHERE filteredlead.statecode = 0";
            SqlCRM_Prospect.SelectCommand = strQuery;
            break;
        }
        if (type != ADDRESS)
        {
          HideProspectAddressColumn();
        }
        gvProspects.PageIndex = 0;
        //try
        //{
        //  SqlCRM_Prospect.DataBind();
        //}
        //catch (Exception ex)
        //{
        //  SqlCRM_Prospect.DataBind();
        //}
        gvProspects.DataBind();
      }

    Markup:

        <div>
         <asp:UpdatePanel ID="pnlSearch" UpdateMode="Conditional" runat="server">
          <ContentTemplate>
             <table ID="tblSearchOptions">
              <tr>
                <td>
                  <asp:TextBox ID="txtSearchString" runat="server" 
                    ontextchanged="txtSearchString_TextChanged"></asp:TextBox>
                </td>
                <td>
                  <asp:Label ID="lblFind" runat="server" Text="Find:" CssClass="NormalLabels"></asp:Label>
                      <asp:DropDownList ID="lstSearchType" runat="server" AutoPostBack="false">
                        <asp:ListItem Value="0">Last, First</asp:ListItem>
                        <asp:ListItem Value="1">Last</asp:ListItem>
                        <asp:ListItem Value="2">First</asp:ListItem>
                        <asp:ListItem Value="3">Liberty ID</asp:ListItem>
                        <asp:ListItem Value="4">E-mail</asp:ListItem>
                        <asp:ListItem Value="5">Telephone</asp:ListItem>
                        <asp:ListItem Value="6">Birthday (exact m/d/yyyy)</asp:ListItem>
                        <asp:ListItem Value="7">SSN (exact ###-##-####)</asp:ListItem>
                        <asp:ListItem Value="8">Address</asp:ListItem>
                      </asp:DropDownList>
                  <asp:CheckBox ID="chkProspects" runat="server" Checked="false" 
                    Text="Show Prospects?" />
                </td>
              </tr>
             </table>
           </ContentTemplate>
         </asp:UpdatePanel>
         <table id="tblContactGrid">
          <tr>
            <td>
              <asp:Label ID="lblContactHeading" runat="server" Text="Contacts" CssClass="h1Labels"></asp:Label>
              <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel_Contact">
                <ProgressTemplate><img alt="Loading. . ." src="/ISV/LUCRMBanner/images/multisearch/loading.gif" style="display:inline; float: left;" /></ProgressTemplate>
              </asp:UpdateProgress>
            </td>
          </tr>
          <tr class="MenuTableRow">
            <td>
              <div id="contact_menu" class="menubar">
                <div id="button_new_contact" onclick="openObj(2);"></div>
                <div class="button_assign" onclick="openAssign(2);"></div>
                <div class="button_merge" onclick="openMerge(2);"></div>
              </div>
            </td>
          </tr>
          <tr class="GridTableRow">
            <td>
              <asp:UpdatePanel ID="UpdatePanel_Contact" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                  <asp:GridView ID="gvContacts" runat="server" DataKeyNames="contactid" AutoGenerateColumns="False" 
                    DataSourceID="SqlCRM_Contact" AllowSorting="true" AllowPaging="true" PageSize="20" 
                    CssClass="SearchGrid" HeaderStyle-CssClass="SearchGridHeader" 
                    RowStyle-CssClass="SearchRows" onrowdatabound="gvContacts_RowDataBound" 
                    EnableViewState="false" EmptyDataText="Your search returned no contacts." EmptyDataRowStyle-CssClass="SearchRows">
                    <Columns>
                      <asp:BoundField DataField="contactid" HeaderText="GUID"
                        ReadOnly="True" SortExpression="contactid" />
                      <asp:BoundField DataField="new_libertyid" HeaderText="Liberty ID" 
                        SortExpression="new_libertyid" ItemStyle-Width="10%" />
                      <asp:BoundField DataField="fullname" HeaderText="Full Name" 
                        SortExpression="fullname" ItemStyle-Width="50%" />
                      <asp:BoundField DataField="line1" HeaderText="Address" 
                        SortExpression="line1" />
                      <asp:BoundField DataField="emailaddress1" HeaderText="E-mail" 
                        SortExpression="emailaddress1" ItemStyle-Width="10%" /> 
                      <asp:BoundField DataField="telephone1" HeaderText="Telephone" 
                        SortExpression="telephone1" ItemStyle-Width="10%"/>
                      <asp:BoundField DataField="birthdate" HeaderText="Birthday" 
                        SortExpression="birthdate" HtmlEncode="false" DataFormatString="{0:d}" ItemStyle-Width="10%" /> 
                      <asp:BoundField DataField="gendercodename" HeaderText="Gender" 
                        SortExpression="gendercodename" ItemStyle-Width="10%" />                                                               
                    </Columns>
                  </asp:GridView>            
                </ContentTemplate>
                <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="txtSearchString" EventName="TextChanged" />
                </Triggers>
              </asp:UpdatePanel>
              <asp:SqlDataSource ID="SqlCRM_Contact" runat="server" 
                ProviderName="System.Data.SqlClient">
              </asp:SqlDataSource>
            </td>
          </tr>
         </table>
         <table id="tblProspectGrid">
          <tr>
            <td>
              <asp:UpdatePanel ID="UpdatePanel_ProspectHeading" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                  <asp:Panel ID="pnlProspectHeading" runat="server">
                    <asp:Label ID="lblProspectHeading" runat="server" Text="Prospects" CssClass="h1Labels"></asp:Label>
                    <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel_Prospect">
                      <ProgressTemplate><img alt="Loading. . ." src="/ISV/LUCRMBanner/images/multisearch/loading.gif" style="display:inline; float: left;" /></ProgressTemplate>
                    </asp:UpdateProgress>
                  </asp:Panel>
                </ContentTemplate>
                <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="txtSearchString" EventName="TextChanged" />
                </Triggers>
              </asp:UpdatePanel>
            </td>
          </tr>
          <tr class="MenuTableRow">
            <td>
            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
              <ContentTemplate>
                <asp:Panel ID="pnlProspectMenu" runat="server">
                  <div id="prospect_menu" class="menubar">
                    <div id="button_new_prospect" onclick="openObj(4);"></div>
                    <div class="button_assign" onclick="openAssign(4);"></div>
                    <div class="button_merge" onclick="openMerge(4);"></div>
                  </div>
                </asp:Panel>
              </ContentTemplate>
              <Triggers>
                <asp:AsyncPostBackTrigger ControlID="txtSearchString" EventName="TextChanged" />
              </Triggers>
            </asp:UpdatePanel>
            </td>
          </tr>
          <tr class="GridTableRow">
            <td>
              <asp:UpdatePanel ID="UpdatePanel_Prospect" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                  <asp:GridView ID="gvProspects" runat="server" DataKeyNames="leadid" AutoGenerateColumns="False" 
                    DataSourceID="SqlCRM_Prospect" AllowSorting="true" AllowPaging="true" PageSize="20" 
                    CssClass="SearchGrid" HeaderStyle-CssClass="SearchGridHeader" 
                    RowStyle-CssClass="SearchRows" onrowdatabound="gvProspects_RowDataBound" 
                    EnableViewState="false" EmptyDataText="Your search returned no prospects." EmptyDataRowStyle-CssClass="SearchRows">
                    <Columns>
                      <asp:BoundField DataField="leadid" HeaderText="GUID"
                        ReadOnly="True" SortExpression="leadid" />
                      <asp:BoundField DataField="fullname" HeaderText="Full Name" 
                        SortExpression="fullname" ItemStyle-Width="60%" />
                      <asp:BoundField DataField="address1_line1" HeaderText="Address" 
                        SortExpression="address1_line1" />
                      <asp:BoundField DataField="emailaddress1" HeaderText="E-mail" 
                        SortExpression="emailaddress1" ItemStyle-Width="10%" /> 
                      <asp:BoundField DataField="telephone1" HeaderText="Telephone" 
                        SortExpression="telephone1" ItemStyle-Width="10%"/>
                      <asp:BoundField DataField="lu_dateofbirth" HeaderText="Birthday" 
                        SortExpression="lu_dateofbirth" HtmlEncode="false" DataFormatString="{0:d}" ItemStyle-Width="10%" /> 
                      <asp:BoundField DataField="lu_gendername" HeaderText="Gender" 
                        SortExpression="lu_gendername" ItemStyle-Width="10%" />                                                               
                    </Columns>
                  </asp:GridView>            
                </ContentTemplate>
                <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="txtSearchString" EventName="TextChanged" />
                </Triggers>
              </asp:UpdatePanel>
              <asp:SqlDataSource ID="SqlCRM_Prospect" runat="server" 
                ProviderName="System.Data.SqlClient">
              </asp:SqlDataSource>
            </td>
          </tr>
         </table>
        </div>
    
    Monday, May 10, 2010 3:43 PM

Answers

  • You may try to change your connection string to specify a longer timeout if it's sql query timeout issue. It may be something like this:

     

    "Persist Security Info=False;Integrated Security=SSPI;database=MYORG_MSCRM;server=MYSQLServer;Connect Timeout=120"

     


    Daniel Cai | http://danielcai.blogspot.com
    Monday, May 10, 2010 8:49 PM

All replies

  • Sorry for the verbose, terribly long code segments.  It's just going to be hard to give suggestions without seeing exactly what I'm doing.
    Monday, May 10, 2010 3:49 PM
  • Try to change the following line of CRMWeb's web.config file: 

    <add key="DevErrors" value="Off" />

    to

    <add key="DevErrors" value="On" />

     

    And see if you can actually see the error. 


    Daniel Cai | http://danielcai.blogspot.com
    Monday, May 10, 2010 4:06 PM
  • That's already on.

    Could that be why the error is being captured before I can handle it? (Which I have no understanding of how MS would accomplish this...seems like what I'm doing should be contained in the C# language...not something you can edit in  config file)

    Monday, May 10, 2010 4:14 PM
  • How about temporarily disabling UpdatePanel in your page?

    CRM does try to catch all the errors if your custom code resides in the same web application. 


    Daniel Cai | http://danielcai.blogspot.com
    Monday, May 10, 2010 5:07 PM
  • Is the code deployed to your ISV folder, and by extension, executing in the context of the IIS Application Pool assigned to CRM?  I ask, because I make the assumption that the error occurs immediately, rather than delayed by the process hitting a timeout.  In this case, the relevant part of the error is "or the server is not responding."  Are you certain that your code is able to successfully connect to both the server, and the CRM database?


    Dave Berry
    Monday, May 10, 2010 6:25 PM
    Moderator
  • You are correct Dave.  It's in the ISV folder.

    It seems only to happen for long running queries. (though not very long running queries) 

    Monday, May 10, 2010 8:31 PM
  • You may try to change your connection string to specify a longer timeout if it's sql query timeout issue. It may be something like this:

     

    "Persist Security Info=False;Integrated Security=SSPI;database=MYORG_MSCRM;server=MYSQLServer;Connect Timeout=120"

     


    Daniel Cai | http://danielcai.blogspot.com
    Monday, May 10, 2010 8:49 PM
  • I will try increasing the timeout, but this still doesn't answer how I can catch the error. Avoiding the error is one thing, but if my code has no way of detecting when an error has occurred I'm in the same boat.

    Clif

    Tuesday, May 11, 2010 2:25 PM