PRB: ODBC Converts Microsoft Excel Character Data to Memos

Last reviewed: April 30, 1996
Article ID: Q131580
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SYMPTOMS

When using the Microsoft Excel ODBC driver (from the Microsoft Desktop Database Drivers version 2.0) to perform a query against a Microsoft Excel spreadsheet, a Visual FoxPro table or cursor is produced. This table or cursor contains the requested data from the Microsoft Excel spreadsheet. If a cell contains text, that text will appear inside memo fields in the resulting Visual FoxPro table or cursor.

CAUSE

When the data is passed to Visual FoxPro from ODBC, the resulting column is 255 characters wide. Visual FoxPro cannot place more than 254 characters in a character field. Therefore, the data must be placed into a memo field.

WORKAROUND

Add a character field to the table that contains the results of the query. Replace that character field with the contents of the memo field.

For example, if the resulting table contains a memo field called sqlmemo, add a character field with the name sqlchar to the table. Then use the following command to copy the data from the memo field to the character field:

   REPLACE ALL sqlchar WITH TRIM(sqlmemo)

Then remove the memo field from the table.

STATUS

Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Excel version 5.0, create a workbook called ONE.XLS.

  2. Place the word "this" in column 1, row 1 of Sheet1.

  3. Place the word "one" in column 1, row 2 of Sheet1.

  4. Place the word "two" in column 1, row 3 of Sheet1.

  5. Place the word "three" in column 1, row 4 of Sheet1.

  6. Save the workbook as ONE.XLS.

  7. Create a data source called "excel" using the Microsoft Excel ODBC driver. The data source should point to the ONE.XLS file saved in step 6.

  8. Exit from Microsoft Excel, and start Visual FoxPro.

  9. Enter the following commands in the Command window:

    h = SQLCONNECT("excel32","","") ? SQLEXEC(h,'SELECT * FROM "Sheet1$" Sheet1_') BROWSE

    You will see that the Microsoft Excel cells are presented as memo fields.


Additional reference words: 3.00 VFoxWin
KBCategory: kbinterop kbprb
KBSubcategory: FxinteropExcel


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.