I'm calling a stored procedure on a SQL Server 2005 database which returns an XML resultset. Sometimes it will return an null resultset becuase there are not rows to return. When this happens athe ExecuteXmlReader method throws a TargetInvocationException. This seems to be a known issue (see: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/5e90e3c0-605b-406d-848a-dea7b16f458e/).
What is the best way to handle this exception?
views:
553answers:
1
+1
A:
I can think of 3 choices
- Modify stored procedure to return a dummy/empty value
- Modify code - catch exception and do nothing - or log error
- Use DataSet - You should get an empty DataSet so just check if DataSet is empty or not.
As a related SO post for the 3rd choice, here is a SO question on how to check if DataSet is empty or not
Sung Meister
2009-03-03 00:42:09