Microsoft KB Archive/884464

= BUG: One or more columns in the Results pane appear to be empty when you retrieve data in Visual Studio .NET or Visual Studio 2005 =

Article ID: 884464

Article Last Modified on 11/14/2007

-

APPLIES TO


 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Basic 2005
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-





SYMPTOMS
In Microsoft Visual Studio .NET or Visual Studio 2005, one or more columns in the Results pane appear to be empty when you retrieve data from a Microsoft SQL Server 2000 database table. This problem occurs when the following conditions are true:
 * The database table contains a column of type CHAR, NCHAR, VARCHAR, or NVARCHAR.
 * The column contains data that has more than 900 characters.



CAUSE
The cells of the Results pane in Visual Studio .NET or Visual Studio 2005 cannot display data that has more than 900 characters.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
If you use the VARCHAR data type for a column instead of the CHAR data type, and you use the NVARCHAR data type for a column instead of the NCHAR data type, the cell of the Results pane will display data that has up to 900 characters.

However, when you enter data that has more than 900 characters, the data will not appear in the cell of the Results pane. You will again notice that the cell of the Results pane is empty.

Steps to reproduce the problem
 Create a database table. To do this, follow these steps:  Start SQL Query Analyzer. On the File menu, click New. Click Blank Query Window, and then click OK.  Put the following code in the query window. This code creates the MyDatabase database and the MyTable table. All the columns of the first row in the MyTable table contain data that has 900 characters. All the columns of the second row in the MyTable table contain data that has 901 characters. DROP DATABASE MyDatabase GO CREATE DATABASE MyDatabase GO USE MyDatabase GO CREATE TABLE MyTable (  Col1    char(1000)  NOT NULL,    Col2    nchar(1000) NOT NULL,    Col3    varchar(1000)   NOT NULL,    Col4    nvarchar(1000)   NOT NULL ) SET NOCOUNT ON GO INSERT INTO MyTable VALUES ( REPLICATE('1', 900),  REPLICATE('2', 900),  REPLICATE('3', 900),  REPLICATE('4', 900) ) GO INSERT INTO MyTable VALUES ( REPLICATE('1', 901),  REPLICATE('2', 901),  REPLICATE('3', 901),  REPLICATE('4', 901) ) GO </ol> </li> Create a database connection from Visual Studio .NET or from Visual Studio 2005. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Start Visual Studio .NET or Visual Studio 2005.</li> On the View menu, click Server Explorer.</li> In Server Explorer, right-click Data Connections, and then click Add Connection. The Data Link Properties dialog box appears.

Note In Visual Studio 2005, click Add Connection.</li> In the Data Link Properties dialog box, click the Connection tab.

Note In Visual Studio 2005, click Add Connection.</li> In the Select or enter a server name box, type.

Note  is a placeholder for the address of the computer that contains the MyDatabase database in SQL Server 2000.</li> In the User name box, type.

Note  is a placeholder for the user name that you use to log on to SQL Server 2000. This user name authenticates your connection to the database server.</li> In the Password box, type.

Note  is a placeholder for the password that you use to connect to the database server.</li> Select the Allow saving password check box.</li> In the Select the database on the server box, select MyDatabase, and then click OK.</li> Expand MyDatabase, and then expand Tables.</li> Right-click MyTable, and then click Retrieve Data from Table.</li></ol> </li></ol>

Notice that the first two columns of the Results pane appear to be empty. The data type of the first column is CHAR and the data type of the second column is NCHAR. Each of these columns has a field size of 1000 characters. The first two columns of the Results pane will always appear to be empty, regardless of the data that the columns contain.

The data type of the third column is VARCHAR and the data type and the fourth column is NVARCHAR. Notice that the third column and the fourth column of the first row in the Results pane contain data. The data in the third column and in the fourth column of the first row have 900 characters.

Notice that the third column and the fourth column of the second row in the Results pane do not contain any data. The data in the third column and in the fourth column of the second row have 901 characters.

Therefore, a column that has a data type of CHAR, VARCHAR, NCHAR, or NVARCHAR, and that has more than 900 characters, does not appear in the Results pane in Visual Studio .NET or in Visual Studio 2005.

<div class="references_section">