ExecuteNonQuery: Connection property has not been initialized = possible deadlock?

  • hiya,

    I'm getting the above error intermittently with some .net code.

    The query seems fine, as it works most of the time.

    My 2 trains of thought are either:

    1) Maybe the connection pool's run out of connections (doubtful though, as I suppose that it'd probably throw a different exception)

    2) There's a deadlock somewhere...In which case I could try this:

    http://blogs.msdn.com/b/bartd/archive/2006/09/09/deadlock-troubleshooting_2c00_-part-1.aspx

    Any thoughts?

    Ta,

    yogi

  • If the error is recreatable then I would have profiler running on the SQL server and see what you find there. Also check the SQL Logs to see if anything is being reported.

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • Depending on the version of .NET you may be missing Dispose, Dispose Bool or Using statement to clean out and close connections.

    Kind regards,
    Gift Peddie

  • Gift Peddie (4/26/2011)


    Depending on the version of .NET you may be missing Dispose, Dispose Bool or Using statement to clean out and close connections.

    This. I don't think a deadlock would be causing "Connection property has not been initialized."

    Any chance you could post a code snippet?

  • I'm getting the above error intermittently with some .net code.

    The query seems fine, as it works most of the time.

    You are commenting about the posters train of thought I am commenting about the ExecuteNonQuery Object which generally errors out when connection is not disposed or dispose is not called automatically by a Using statement in C# from 1.1 and VB.NET 2.0 and up. I wanted to add please post some relevant code.

    Kind regards,
    Gift Peddie

  • Yes, I know. I was quoting you to agree and to ask the OP to post some source code. Sorry for the confusion.

    🙂

  • dmbaker (4/27/2011)


    Yes, I know. I was quoting you to agree and to ask the OP to post some source code. Sorry for the confusion.

    🙂

    My bad lets hope the poster share some relevant code with us.

    🙂

    Kind regards,
    Gift Peddie

  • hiya guys,

    ta for the replies.I don't have the code to hand as it's in the office, but I'll look for potential for non-disposed connections and get back to you.

    Many thanks,

    yogi

  • OK, well, if you're coding in C# and you're not using "using" when instantiating your connection object(s) or you're not explicitly calling "dispose()" on the connection objects then you might be causing problems. Don't think we need to see any code to recommend that so look for that, to be sure.

    Same thing in VB.NET, I expect, although I don't know what the "using" construct looks like in VB.NET.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply