Microsoft KB Archive/195528

= BUG: WFC DataGrid Control Fails When Displaying a Binary Column =

Article ID: 195528

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Software Development Kit for Java 3.1
 * Microsoft Software Development Kit for Java 3.2

-



This article was previously published under Q195528



SYMPTOMS
An attempt to display a binary field in a Windows Foundation Classes (WFC) DataGrid control may cause an Application Error.



CAUSE
An underlying call to field.getString fails.



RESOLUTION
Avoid using the DataGrid control to display binary data, if possible.

If you are writing code that directly manipulates binary fields, use field.getValue instead of field.toString.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Using Visual J++, create a new empty project. Add a new WFC Form to the project. Add a DataSource to the Form by dragging a DataSource control over from the Toolbox. In the Properties pane for the DataSource, set the connectionString property by selecting that field and clicking on the "..." button. Select a database that contains a binary field. You can follow these steps if you have Microsoft Access and the Northwind sample database installed.  A "Data Link Properties" dialog box will appear. Click the Provider tab and select "Microsoft Jet 3.51 OLE DB Provider." Click Next or the Connection tab. Type in the path to the Northwind database, or click the "..." button to browse for it. The Northwind database is commonly located at C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb.</li> Click on the Test Connection button to test the data source.</li> Click OK.</li></ol> </li> In Properties for the DataSource, select the commandText property and type in a command string that describes a table with binary data in at least one column. If you are using the Northwind database, you can type in select * from employees.</li> In Properties for the DataSource, select the cursorLocation property and choose the value Server.</li> Add a DataGrid control to the Form by selecting the DataGrid control from the Toolbox and dragging out its shape on the Form.</li> In the Properties pane for the DataGrid, select the dataSource property and choose the DataSource you added in step 2.

NOTE: Data from the database will appear in the DataGrid, and Visual Studio may stop if a field with binary data is visible at this point.</li> Run the application.</li> Scroll the DataGrid to reveal the column with binary data. If you are using the Northwind database as described above, this will be the Photo column.</li></ol>

At this point, the program attempts to access memory that is invalid. You will see a dialog box similar to the following:

WJView.exe - Application Error The instruction at "0x7c01254d" referenced memory at "0x056f2000". The memory could not be "read". Click on OK to terminate the application Click on CANCEL to debug the application"

<div class="references_section">