Re: InvalidCastException Hangs W/ Stored Procedure Output Parameter

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 10/05/04


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


Relevant Pages

  • InvalidCastException Hangs W/ Stored Procedure Output Parameter
    ... The only way I see the exception is when I run the program w/ ... sucking up memory unless I kill it. ... I thought (even if running w/o ...
    (microsoft.public.dotnet.csharp.general)
  • InvalidCastException Hangs W/ Stored Procedure Output Parameter
    ... The only way I see the exception is when I run the program w/ ... sucking up memory unless I kill it. ... I thought (even if running w/o ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How to troubleshoot bugchecks on my own?
    ... not a memory problem. ... From that exception record and context, ... execute the instruction - without a problem. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Bsod irql_not_less_or_equal
    ... *** Memory manager detected 2 instanceof page corruption, ... likely to have memory corruption. ... the driver/function that caused the problem. ... The exception code that was not handled ...
    (microsoft.public.windows.vista.performance_maintenance)
  • Re: Strange sudden shutdown issue with CF app
    ... Phone devices are notoriously low on virtual memory right out of the box because the OEMs decide to put every little thing into its own DLL and then have 25 processes launched at boot. ... Chris Tacke, Embedded MVP ... We have created an app that basically connects to a web service gets data, then stores it locally on the device, and when a record needs to be modified/added the system first tries to connect the web server sees if its availible, if not then it stores in locally on the device until the connection comes back, now I noticed that if the device does not mess around with the data connection then the application sits nicely as long as its open, and never gets shut down. ... But again most of the time I get no exception at all but just simply disappears. ...
    (microsoft.public.dotnet.framework.compactframework)