How to Handle Embedded Space in Field Name in FoxPro

Last reviewed: June 27, 1995
Article ID: Q130161
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6a

SUMMARY

FoxPro does not support field names that contain spaces (embedded blanks). However, other database applications such as Paradox and Microsoft Access do. If you use the Connectivity Kit (CK), FoxPro can access the fields that contain spaces, but in order to reference the field in an SQL SELECT statement that is passed to DBExec(), you must surround the field name with square brackets - [ and ].

MORE INFORMATION

Native FoxPro does not support fields that contain spaces in the names. Therefore, when FoxPro retrieves data from another data source that contains a space in the field name, FoxPro replaces the space with an underscore.

Many times it is necessary to access a field that contains a space in its name with a SQL SELECT statement that is passed to the DBExec() function. The following example demonstrates how to use the square brackets to reference the field name:

   SET LIBRARY TO SYS(2004)+"fpsql.fll"
   handle=DBConnect("atest","","")
   =DBExec(handle,"select * from test where [abc def]='rec1'")
   =DBDisconn(handle)
   SET LIBRARY TO


Additional reference words: FoxWin 2.60a ODBC
KBCategory: kbprg kbtool kbcode
KBSubcategory: FxtoolCk


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.