次の方法で共有


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.

    Warning

    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 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.

Remarks

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

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

Reference

ADD TABLE Command

CREATE DATABASE Command

CURSORGETPROP( ) Function

CURSORSETPROP( ) Function

DBGETPROP( ) Function

DISPLAY DATABASE Command

LIST DATABASE Command

OPEN DATABASE Command

SQLCOMMIT( ) Function

SQLROLLBACK( ) Function

Other Resources

Functions

Language Reference (Visual FoxPro)