How to Handle Embedded Space in Field Name in FoxPro

ID: Q130161

2.60a WINDOWS kbprg kbtool kbcode

The information in this article applies to:

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

Last Reviewed: November 22, 1998