> I'vw decided to use a try-catch setup, because of a recurring bug. I
> started off with just catch (SqlException), and that worked, so I got
[quoted text clipped - 21 lines]
> }
> return m_Rdr;
On Apr 4, 10:18 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.com> wrote:
> At a minimum, for the code to even compile successfully, it would need to
> look like this:
[quoted text clipped - 56 lines]
>
> - Show quoted text -
That's not answering my question. Why is the catch (Exception)
getting called so often. When I remove I do not get a unhandled
exception.
As far as the business logic, the method returns a SqlDataReader. In
the case of a catch, I want SqlDataReader will still return, but it is
empty, ie, it has no records. This seemed like an easy way out of my
problem. But I take your point.
Dom
Peter Duniho - 05 Apr 2008 03:31 GMT
> [...]
> That's not answering my question.
Sometimes the first step is to help the person asking the question to
rephrase their question so that it makes sense. Both Arne and Peter B.
have tried to do that.
Neither Peter's nor your attempt to fix the original code is correct, as
there are still missing semi-colons. But more importantly, you haven't
provide a complete code example, nor have you precisely described what's
going on. Without at least one or the other, it's impossible to answer
the question.
> Why is the catch (Exception)
> getting called so often. When I remove I do not get a unhandled
> exception.
What exception is being thrown? In what context is that method being
called?
If you're catching an exception, it almost certainly was happening before
and you just didn't notice it. But for anything more specific than that,
we need a more specific question.
Pete
scottmyers - 07 Apr 2008 06:54 GMT
> On Apr 4, 10:18 pm, Peter Bromberg [C# MVP]
>
[quoted text clipped - 72 lines]
>
> - Show quoted text -
Is the command that you are trying to execute the same in all 3
cases(the try, the catch SqlException, the catch Exception blocks)?
The whole idea of catching an exception is not so that you can try and
do exactly the same thing again, give us an explanation of what you
are trying to do and include the command text.