The exception that is generated when Dynamics CRM returns an error.
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 [email protected];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 [email protected];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
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