BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
SQL XML
.NET SqlXmlAdapter Classes
.NET SqlXmlParameter Class
.NET SqlXmlCommand Class
.NET Managed Classes
Annotating .NET Updategrams
SQLXML - .NET Updategrams
.NET XPath Queries
SQLXML - Mapping Relationships To XML
SQLXML - Mapping .NET Schemas
.NET & OPENXML
.NET Parameterized Templates
SQLXML - Raw mode
SQLXML - FOR XML mode
Automate saving options from ADO into an XML format
Microsoft's dataselect functionality in the XML DSO
VB/ADO to DataIsland
Inserting nodes: String Load or Dom Load?
WebDAVExplorer
XML-based Internet RPC (XIR)
XDO
<< SEO
System.XML >>

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :219

 

.NET SqlXmlException Class

The managed SQLXML classes throw a SqlXmlException to report any errors that occurred during the execution of a method. This class extends the System.Excpetion class and thus provides all the properties you are used to examine when you catch exceptions in a .NET application.

However, there are some cases where the HResult and the Message property do not provide enough information. Especially errors occurring during the execution of Updategrams often return an ambiguous HResult with the hexadecimal value 0x80040e21 and insufficient information in the Message property. In these cases we have to parse at the SqlXmlException’s  ErrorStream property. The ErrorStream contains the execution results – of course also in XML format where execution errors are reported as processing instructions.

One way to get to the details of the exception is to parse the ErrorStream with an XmlTextReader as outlined in the next code fragment:

try

{

    // do some SQLXML stuff

}

catch( SqlXmlException ex )

{

  XmlTextReader xmlReader = new XmlTextReader( _Ex.ErrorStream );

  while( xmlReader.Read() )

  {

    if( ( XmlNodeType.ProcessingInstruction == xmlReader.NodeType )

      && ( "MSSQLError" == xmlReader.Name ) )

    {

          Console.WriteLine( xmlReader.Value );

    }

  }

}

Of course this example is not very useful because it writes the error to the console. I have taken a more useful approach in an small class you can find on the web site. It parses the ErrorStream property and return all errors in a collection similar to the SqlErrors collection in the System.Data namespace.

TIP: In cases where even the SqlXmlException still does not provide enough details your best bet is to spy on SQLXML with SQL Server’s profiler tool. This tool will show you exactly what queries SQLXML sends to the database. Make sure you run the profiler in a test environment, not in a production environment because it does occupy a fair amount of processing cycles on your database server.


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C
Immediate ASP.NET/C# Openings for C
Sr. Software Engineer

View all Jobs (Add yours)
View all CV (Add yours)



saveonconferences uk rates
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses
bigfoot conferencing


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP