"General network error" error message when you use the Visual Studio .NET debugger to debug an ADO application that contains Transact-SQL code (817181)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

When you use the Microsoft Visual Studio .NET debugger to debug an ActiveX Data Objects (ADO) application that contains Transact-SQL code, you may receive the following error message:
System.Data.SqlClient.SqlException: General network error. Check your network documentation.
You may notice this behavior when you restart Microsoft SQL Server while debugging the ADO application.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the problem

  1. Start SQL Query Analyzer.
  2. Connect to an instance of SQL Server, and then run the following Transact-SQL statement to create a stored procedure in the Pubs database:
    Use pubs
    go
    CREATE PROCEDURE Test_Proc @OutParam int = 10 OUTPUT AS 
    select @OutParam = 20
    RETURN @OutParam
    
  3. Start Visual Studio .NET.
  4. Use Microsoft Visual C# .NET to create a Windows Application project that is named ADODebugging. By default, the Form1.cs file is created.
  5. In the Form1.cs file, locate the following code:
    using System.Data;
  6. Add the following code after the code that you located in the previous step:
    using System.Data.SqlClient;
  7. Add a Button control to the Form1 form.
  8. Add the following code to the button1_Click event handler.

    Note In the following code, replace "MySQLServer" with the name of your SQL Server.
    SqlConnection connection = new SqlConnection("Data Source=MySQLServer;" +
       "initial catalog=Pubs;Integrated Security=SSPI;");
    SqlCommand command = new SqlCommand();
    			
    command.CommandType=CommandType.StoredProcedure;
    command.Connection = connection;
    command.CommandText = "Test_Proc";
    			
    IDbDataParameter param = command.CreateParameter();
    			
    param.ParameterName = "@OutParam";
    param.DbType = DbType.Int32;
    param.Direction = ParameterDirection.Output;
    			
    command.Parameters.Add(param);
    
    try
    {
     connection.Open();
     command.ExecuteNonQuery();								
    }
    catch(Exception ex)
    {
     MessageBox.Show(ex.ToString());
    }
    
    connection.Close();
    
  9. On the Build menu, click Build Solution.
  10. In the Code window, set a breakpoint on the following statement:
    command.ExecuteNonQuery();
  11. On the Debug menu, click Start. By default, the Form1 form appears.
  12. On the Form1 form, click button1.

    Note You notice that the program stops at the breakpoint that you have set.
  13. Restart the instance of SQL Server that you connected to in step 2.
  14. On the Debug menu, click Continue.

Modification Type:MajorLast Reviewed:1/9/2004
Keywords:kberrmsg kbDebug kbTSQL kbprb KB817181 kbAudDeveloper