Condividi tramite


DBSETPROP( ) Function

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

DBSETPROP(cName, cType, cProperty, ePropertyValue)

Parameters

  • cName
    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:

    customer.custid
    
  • cType
    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
    CONNECTION cName is a named connection in the current database.
    DATABASE cName is the current database.
    FIELD cName is a field in the current database.
    TABLE cName is a table in the current database.
    VIEW cName is a view in the current database.
  • cProperty
    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( ).

  • ePropertyValue
    Specifies the value to which cProperty is set. ePropertyValue must be the same data type as the property's data type.

    Caution   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:

         <databaseName>!ePropertyValue

Return Values

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.

Remarks

To determine the current property values, see and use DBGETPROP( ) Function. For more details about the property settings you can retrieve for connections, databases, fields, tables, and views, refer to the topics listed in the following table.

For details about Refer to this topic In this section
Database properties Viewing and Setting Database Properties Creating Databases
Connections Accessing Remote Data Creating Views
Views   Creating Views
Triggers Trigger Usage Working with Tables
Captions Controlling Display of a Field Working with Tables
Default values Creating Default Field Values Working with Tables
  Creating Default Values for View Fields Creating Views
Comments "Adding Comments to Fields" under Choosing Data Types Working with Tables
  Viewing and Setting Database Properties Creating Databases
Primary key Controlling Duplicate Values Working with Tables
Rules Enforcing Business Rules Working with Tables
  Setting or Changing Field-Level or Table Rules Working with Tables
  Creating Rules on View Fields and Rows Creating Views

Example

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.

CLOSE DATABASES
CLEAR

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

ADD TABLE | CREATE DATABASE | CURSORGETPROP( ) | CURSORSETPROP( ) | DBGETPROP( ) | DISPLAY DATABASE | LIST DATABASE | OPEN DATABASE | SQLCOMMIT( ) | SQLROLLBACK( )