Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2005, 07:58 AM
Authorized User
 
Join Date: Jul 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default System.InvalidOperationException: connection dead

Hi

I've written a very simple ASP/VB.NET programme that works fine on my Windows 2000 Pro machine but on XP Pro (SP2) produces

Exception Details: System.InvalidOperationException: The connection is dead.

Source Error:


Line 48:
Line 49: 'execute the command
Line 50: objCmd.ExecuteNonQuery()
Line 51:
Line 52: lblStatus.Text = "Command Run"

Source File: C:\Inetpub\wwwroot\Voice_Console\test.aspx.vb Line: 50

Stack Trace:


[InvalidOperationException: The connection is dead.]
   System.Data.Odbc.OdbcConnection.ConnectionIsAlive( Exception
innerException) +252
   System.Data.Odbc.OdbcConnection.get_State() +12
   System.Data.Odbc.OdbcConnection.get_IsOpen() +5
   System.Data.Odbc.OdbcConnection.GetDriverUnhandled () +18
   System.Data.Odbc.OdbcConnection.HandleErrorNoThrow (HandleRef hrHandle,
SQL_HANDLE hType, RETCODE retcode) +438
   System.Data.Odbc.OdbcConnection.HandleError(Handle Ref hrHandle,
SQL_HANDLE hType, RETCODE retcode) +18
   System.Data.Odbc.OdbcDataReader.NextResult() +356
   System.Data.Odbc.OdbcDataReader.FirstResult() +42
   System.Data.Odbc.OdbcCommand.ExecuteReaderObject(C ommandBehavior
behavior, String method) +1189
   System.Data.Odbc.OdbcCommand.ExecuteNonQuery() +152
   Voice_Console.test.Page_Load(Object Sender, EventArgs E) in
C:\Inetpub\wwwroot\Voice_Console\test.aspx.vb:50
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35

My code contains:

<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.Odbc"%>

<script language="VB" runat="server">

Sub Page_Load(Sender As object, E as EventArgs)

    Dim objConnection As OdbcConnection
    Dim objCmd As OdbcCommand
    Dim strConnection As String
    Dim strSQL As string

    strConnection = "DSN=books.udd"

    'create and open the connection object
    objConnection = New OdbcConnection(strConnection)
    objConnection.Open()

    'set SQL string
    strSQL = "UPDATE CUSTOMER SET CUST_REGION='OST' WHERE CUSTCODE='C001'"


    'create the command and set its properties
    objCmd = New OdbcCommand(strSQL, objConnection)

    'execute the command
    objCmd.ExecuteNonQuery()

    lblStatus.Text = "Command Run"

End Sub
</script>

<html>
    <body>
        <h2>My Test</h2>
        <asp:Label id="lblStatus" runat="server" />
    </body>
</html>

On W2K the code executes and the data (on a Unix machine) is changed fine. It's only when I run it on my XP machine it fails.

Any ideas would be great

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
is kazaa dead? klruser Forum and Wrox.com Feedback 1 March 26th, 2008 11:24 AM
invalidoperationexception? qiux General .NET 0 January 23rd, 2008 11:39 PM
system.InvalidOperationException furjaw Visual Basic 2005 Basics 0 May 27th, 2006 12:44 AM
System.TypeInitializationException w connection fig000 ADO.NET 2 February 9th, 2004 06:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.