Skip to content

Instantly share code, notes, and snippets.

@vrySantosh
Last active July 20, 2020 10:23
Show Gist options
  • Save vrySantosh/e3f40bfab44cc8422c2bd75b675ec5d4 to your computer and use it in GitHub Desktop.
Save vrySantosh/e3f40bfab44cc8422c2bd75b675ec5d4 to your computer and use it in GitHub Desktop.
StringBuilder errorMessages = new StringBuilder();
catch (SqlException ex)
{
for (int i = 0; i < ex.Errors.Count; i++)
{
errorMessages.Append("Index #" + i + "\n" +
"Message: " + ex.Errors[i].Message + "\n" +
"LineNumber: " + ex.Errors[i].LineNumber + "\n" +
"Source: " + ex.Errors[i].Source + "\n" +
"Procedure: " + ex.Errors[i].Procedure + "\n");
}
Console.WriteLine(errorMessages.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment