Re: InvalidCastException Hangs W/ Stored Procedure Output Parameter
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 10/05/04
- Next message: Anonymouse: "Passing events between forms"
- Previous message: Phill: "InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- In reply to: Phill: "InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- Next in thread: Phill: "Re: InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- Reply: Phill: "Re: InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 5 Oct 2004 20:42:56 +0100
Phill <wackyphill@yahoo.com> wrote:
> I have a SQL Server stored procedure that returns an int. Sometimes a
> null value is returned which causes the problem.
>
> //This is what I did:
> return (int)cmd.Parameters["nextCount"].Value;
>
>
> //What I should do is this:
> if( cmd.Parameters["nextCount"].Value != DBNull.Value )
> {
> return (int)cmd.Parameters["nextCount"].Value;
> }
>
> The only way I see the exception is when I run the program w/
> debugging. Because the program seems to hang on that line and keeps
> sucking up memory unless I kill it. I thought (even if running w/o
> debugging) an exception would halt the program and since I have no
> catch blocks should stop the program and display an exception. But the
> program keeps running in task manager and keeps sucking up a little
> more memory all the time?
>
> Why is this?
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Anonymouse: "Passing events between forms"
- Previous message: Phill: "InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- In reply to: Phill: "InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- Next in thread: Phill: "Re: InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- Reply: Phill: "Re: InvalidCastException Hangs W/ Stored Procedure Output Parameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|