BUG: WFC DataGrid Control Fails When Displaying a Binary Column (195528)



The information in this article applies to:

  • Microsoft Visual J++ 6.0
  • Microsoft SDK for Java 3.1
  • Microsoft SDK 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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Using Visual J++, create a new empty project. Add a new WFC Form to the project.
  2. Add a DataSource to the Form by dragging a DataSource control over from the Toolbox.
  3. 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.
    1. A "Data Link Properties" dialog box will appear. Click the Provider tab and select "Microsoft Jet 3.51 OLE DB Provider."
    2. 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.
    3. Click on the Test Connection button to test the data source.
    4. Click OK.
  4. 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.
  5. In Properties for the DataSource, select the cursorLocation property and choose the value Server.
  6. Add a DataGrid control to the Form by selecting the DataGrid control from the Toolbox and dragging out its shape on the Form.
  7. 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.
  8. Run the application.
  9. 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.


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"

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbJava kbpending kbui kbWFC KB195528