JavaScript Editor js editor     Web development 

Main Page

Sets a property for the current database or for fields, named connections, tables, or views in the current database.

DBSETPROP(cName, cType, cProperty, ePropertyValue)



Specifies the name of the current open database or the field, named connection, table, or view in the current open database for which DBGETPROP(В ) returns information. To set a property for a field in a table or a view, preface the name of the field with the name of the table or view containing the field. For example, to set a property for the custid field in the customer table, specify the following for cName:
В Copy Code

Specifies whether cName is the current database or for a field, named connection, table, or view in the current database. The following table lists the values you can specify for cType:

cType Description


cName is a named connection in the current database.


cName is the current database.


cName is a field in the current database.


cName is a table in the current database.


cName is a view in the current database.


Specifies the name of the property to set. If a property is read-only, its value cannot be changed with DBSETPROP(В ). If you attempt to set a property that is read-only, Visual FoxPro generates an error message. For more information on properties you can specify with cProperty, including their data types, see DBGETPROP(В ).

Specifies the value to which cProperty is set. ePropertyValue must be the same data type as the property's data type.
Visual FoxPro does not verify that the value you specify is valid for the property. Thus, it is possible to set a property to an invalid value with DBSETPROP(В ). For example, DBSETPROP(В ) can be used to set a field rule expression to an expression that is not valid for the field, and Visual FoxPro will not generate an error. To avoid an error when setting the Tables property of a view, precede ePropertyValue with the database designation in the following syntax:

В Copy Code

Return Value

Logical data type. DBSETPROP(В ) returns True (.T.) if Visual FoxPro successfully sets the property you specify. Visual FoxPro generates an error if the property you specify cannot be set.


For more information about retrieving current property values, see DBGETPROP(В ) Function.


The following example uses DBSETPROP(В ) to specify a comment for the cust_id field in the customer table. DBGETPROP(В ) is used to display the comment.

В Copy Code

OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer     && Open customer table

= DBSETPROP("customer.cust_id", "Field", "Comment", ;
  "Property has been set by DBSETPROP.")  && New field comments

cRESULTS = DBGETPROP("customer.cust_id", "Field", "Comment")
WAIT WINDOW "Cust_id field comments: "+ cRESULTS  && Display comments

See Also

JavaScript Editor js editor     Web development