Microsoft KB Archive/817181

= &quot;General network error&quot; error message when you use the Visual Studio .NET debugger to debug an ADO application that contains Transact-SQL code =

Article ID: 817181

Article Last Modified on 1/9/2004

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * 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.



Steps to reproduce the problem
 Start SQL Query Analyzer.  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  Start Visual Studio .NET. Use Microsoft Visual C# .NET to create a Windows Application project that is named ADODebugging. By default, the Form1.cs file is created.  In the Form1.cs file, locate the following code: using System.Data;   Add the following code after the code that you located in the previous step: using System.Data.SqlClient;  Add a Button control to the Form1 form.</li>  Add the following code to the button1_Click event handler.

Note In the following code, replace &quot;MySQLServer&quot; with the name of your SQL Server. SqlConnection connection = new SqlConnection(&quot;Data Source=MySQLServer;&quot; +  &quot;initial catalog=Pubs;Integrated Security=SSPI;&quot;); SqlCommand command = new SqlCommand; command.CommandType=CommandType.StoredProcedure; command.Connection = connection; command.CommandText = &quot;Test_Proc&quot;; IDbDataParameter param = command.CreateParameter; param.ParameterName = &quot;@OutParam&quot;; 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; </li> On the Build menu, click Build Solution.</li>  In the Code window, set a breakpoint on the following statement: command.ExecuteNonQuery; </li> On the Debug menu, click Start. By default, the Form1 form appears.</li> On the Form1 form, click button1.

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

Keywords: kberrmsg kbtsql kbdebug kbprb KB817181

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.