Microsoft KB Archive/130161

{| = How to Handle Embedded Space in Field Name in FoxPro =
 * width="100%"|

ID: Q130161

2.60a WINDOWS kbprg kbtool kbcode

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.6a, 3.0, 5.0, 6.0

SUMMARY
FoxPro does not support field names that contain spaces (embedded blanks). However, other database applications such as Paradox and Microsoft Access do field names that contain spaces. 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 Keywords         : kbVFp300 kbVFp500 kbVFp600 kbVFP260 Version          : WINDOWS: 2.6,3.0,5.0,6.0
 * }