dotConnect for Dynamics 365 Documentation
Devart.Data.Dynamics Namespace / DynamicsException Class
Members Example

    DynamicsException Class
    The exception that is generated when Dynamics 365 returns an error.
    Syntax
    Remarks
    This class is created whenever dotConnect for Dynamics 365 encounters an error generated by the server, or DynamicsConnection has been closed before attempting to execute an operation on the server.
    Example
    The following example generates a DynamicsException due to a non-existing table, and then displays the exception.
    public void ThrowDynamicsException()
    {
      string mySelectQuery = "SELECT * FROM NONEXISTINGTABLE";
      DynamicsConnection dynamicsConnection =
        new DynamicsConnection(
            "Server=https://your_company.crm4.dynamics.com;User Id=Test@Test.onmicrosoft.com;Password=A123456789;");
      DynamicsCommand dynamicsCommand = new DynamicsCommand(mySelectQuery,dynamicsConnection);
      try
      {
        dynamicsCommand.Connection.Open();
      }
      catch (DynamicsException myException)
      {
        MessageBox.Show("Message: " + myException.Message + "\n");
      }
    }
    Public Sub ThrowDynamicsException()
      Dim mySelectQuery As String = "SELECT * FROM NONEXISTINGTABLE"
      Dim dynamicsConnection As New DynamicsConnection( _
        "Server=https://your_company.crm4.dynamics.com;User Id=Test@Test.onmicrosoft.com;Password=A123456789;")
      Dim dynamicsCommand As New DynamicsCommand(mySelectQuery, dynamicsConnection)
      Try
        dynamicsCommand.Connection.Open()
      Catch myException As DynamicsException
        MessageBox.Show("Message: " + myException.Message + ControlChars.Cr)
      End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.Exception
          System.SystemException
             System.Runtime.InteropServices.ExternalException
                System.Data.Common.DbException
                   Devart.Data.Dynamics.DynamicsException

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also