Click or drag to resize

DbGetProp Function

X#
Retrieves the value of a property for the current database or for fields, named connections, tables, or views in the current database.
Note Note
You must open the database before you can retrieve its properties or those of its connections, tables, views, or fields. However, you do not need to open a table or view before retrieving its properties.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION DbGetProp(
	cName AS STRING,
	cType AS STRING,
	cProperty AS STRING
) AS USUAL
Request Example View Source

Parameters

cName
Type: String
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 return information about 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 return information about the custid field in the customer table, specify the following for cName:
X#
1customer.custid
cType
Type: String
Specifies whether cName is the current database, or a field, named connection, table, or view in the current database. The table in the remarks section lists the values for cType.
cProperty
Type: String
Specifies the name of the property for which DbGetProp( ) returns information.
The tables in the remarks section list the values you can specify for cProperty, the return value types, and descriptions of each property. Each description includes the read and write privileges for each property. If a property is read-only, its value cannot be changed with DbSetProp( ).

Return Value

Type: Usual
Character, Numeric, or Logical data type. DbGetProp( ) returns the value for the specified property.
Remarks
For more information about setting property values, see DbSetProp( ) Function.
cTypeDescription
ConnectioncName is a named connection in the current database.
DatabaseName is the current database.
FieldcName is a field in the current database.
TablecName is a table in the current database.
View cName is a view in the current database.
Connection properties
cPropertyTypeDescription
AsynchronousL The connection mode. (Default) False (.F.) specifies a synchronous connection. True (.T.) specifies an asynchronous connection.
BatchModeL The batch-processing mode. (Default) True (.T.) specifies the connection that operates in batch mode.
CommentCThe text of the connection comment.
ConnectStringCThe login connection string.
ConnectTimeoutNThe connection timeout interval in seconds. The default is 0 (wait indefinitely).
DatabaseCThe name of the server database specified with the Database clause in the Create Connection command or in the Connection Designer.
DataSourceCThe name of the data source as defined in the Odbc.ini file.
DisconnectRollbackL Specifies if a pending transaction is committed or rolled back when SqlDisconnect( ) is called for the last connection handle.
The default is false (.F.), indicating that a pending transaction is committed when SqlDisconnect( ) is called for the last connection handle.
Specify true (.T.) to roll back a pending transaction when SqlDisconnect( ) is called for the last connection handle.
Connections with automatic transaction processing are not affected by this setting.
DispLoginN Contains a numeric value that determines when the ODBC Login dialog box is displayed. DispLogin may assume the following values:
1 or DB_PROMPTCOMPLETE (from Foxpro.h). 1 is the default.
2 or DB_PROMPTALWAYS (from Foxpro.h).
3 or DB_PROMPTNEVER (from Foxpro.h).
If 1 or DB_PROMPTCOMPLETE is specified, X# displays the ODBC Login dialog box only if any required information is missing.
If 2 or DB_PROMPTALWAYS is specified, the ODBC Login dialog box is always displayed, allowing you to change settings before connecting.
If 3 or DB_PROMPTNEVER is specified, the ODBC Login dialog box is not displayed and X# generates an error if the required login information is not available.
DispWarningsL Contains a logical value that determines if non-trappable warnings from the remote table, ODBC, or X# are displayed. (Default) True (.T.) specifies that non-trappable errors are displayed.
IdleTimeout N The idle timeout interval in minutes. Timeout is checked no more than once per minute, therefore it is possible that active connections might deactivate one or two minutes later after the specified time interval has elapsed. The default value is 0 (wait indefinitely).
PacketSizeN The size of the network packet used by the connection. Adjusting this value can improve performance. The default value is 4096 bytes (4K).
PassWordCThe connection password.
QueryTimeoutNThe query timeout interval in seconds. The default value is 0 (wait indefinitely).
TransactionsN Contains a numeric value that determines how the connection manages transactions on the remote table. Transactions may assume the following values:
1 or DB_TRANSAUTO (from Foxpro.h). 1 is the default. Transaction processing for the remote table is handled automatically.
2 or DB_TRANSMANUAL (from Foxpro.h). Transaction processing is handled manually through SqlCommit( ) and SqlRollBack( ).
UserIdCThe user identification.
WaitTimeN The amount of time in milliseconds that elapses before X# checks whether the SQL statement has completed executing. The default is 100 milliseconds.
Note Note
All of these are read/write


Database properties
cPropertyTypeDescription
CommentC The text of the database comment.
Read/write.
DBCEventFileNameCRelative path and filename of external program file containing DBC Events code.
DBCEventsLEnabled state of DBC Events. Set to True (.T.) to enable.
VersionN The database version number.
Read-only.


Field properties for tables
cPropertyTypeDescription
CaptionC The field caption. If an equal sign (=) precedes the value of this property, X# evaluates the value as an expression. Otherwise, it is treated as a string literal.
CommentC The text of the field comment.
DefaultValueCThe field default value.
DisplayClassCName of the class used for field mapping.
DisplayClassLibraryC Path to the class library specified with the DisplayClass property.
FormatCThe field display format. See the Format Property for a list of format settings.
InputMaskCThe field input format. See the InputMask Property for a list of input mask settings.
RuleExpressionCThe field rule expression.
RuleTextCThe field rule error text.
Note Note
All of these are read/write


Field properties for views
cPropertyTypeDescription
CaptionC The field caption. If an equal sign (=) precedes the value of this property, Visual FoxPro evaluates the value as an expression. Otherwise, it is treated as a string literal.
CommentCThe text of the field comment.
DataTypeC The data type for a field in a view. Initially set to the data type for the field in the data source.
To specify a different data type for a field with DbSetProp( ), use the syntax for creating fields in Create Table – SQL.
For example, to change the data type of an integer field named iCost in a table named Mytable to numeric type with width 4 and 2 decimal places, use DbSetProp('mytable.icost', 'field', ; 'DataType', 'N(4,2)')
You can also include the NOCPTRANS clause to prevent translation of character and memo fields to a different code page.
Read/write for remote views.
DisplayClassCName of the class used for field mapping.
DisplayClassLibraryC Path to the class library specified with the DisplayClass property.
DefaultValueCThe field default value
KeyFieldLContains True (.T.) if the field is specified in an index key expression; otherwise, contains False (.F.).
RuleExpressionCThe field rule expression.
RuleTextCThe field rule error text.
UpdatableLContains True (.T.) if the field can be updated; otherwise, contains False (.F.).
UpdateNameCThe name of the field used when data in the field is updated to the remote table. By default, the remote table field name.
Note Note
All of these are read/write


Table properties
cPropertyTypeDescription
CommentC The text of the table comment.
Read/write.
DeleteTriggerC The Delete trigger expression.
Read-only.
InsertTriggerC The Insert trigger expression.
Read-only.
PathC The relative path with respect to the DBC to the table including the name of the file.
Read-only.
PrimaryKeyC The tag name of the primary key.
Read-only.
RuleExpressionC The row rule expression.
Read-only.
RuleTextC The row rule error text.
Read-only.
UpdateTriggerC The Update trigger expression.
Read-only.


View properties
cPropertyTypeDescription
AllowSimultaneousFetchL Applies when using remote views, a shared connection, and to cursors created using ODBC.
AllowSimultaneousFetch contains True (.T.) when similarly configured cursors sharing the connection are permitted to fetch rows simultaneously.
Otherwise, AllowSimultaneousFetch contains False (.F.) when fetching rows simultaneously is not permitted.
Note Note
This property is available in X# 8.0 and later. Views created in X# 8.0 and later are not compatible with earlier versions. Calling the VALIDATE Database command in a version prior to X# 8.0 on a database container with remote views created or modified in X# 8.0 and later generate an error. Calling the VALIDATE Database RECOVER in a version prior to X# 8.0 removes the AllowSimultaneousFetch property from any such views.
BatchUpdateCountN The number of update statements sent to the back end for views. 1 is the default. Adjusting this value can greatly increase update performance.
Read/write.
CommentC The text of the view comment.
Read/write.
CompareMemoL Contains true (.T.) (default) if memo fields (of type Memo, General, or Picture, or, for remote views, type Timestamp) are included in the Where clause for updates; otherwise, contains false (.F.).
Read/write.
ConnectNameC The named connection used when the view is opened.
Read-only.
FetchAsNeededL If True (.T.), data is fetched only when needed, such as when record pointer moves to a row that has not been fetched.
If False (.F.), additional data is fetched during idle time. (Default)
Note Note
FetchAsNeeded does not apply when progressive fetching is disabled (FetchSize is -1).

Read/write.
FetchMemoL Contains true (.T.) (default) if memo and general fields are fetched with the view results; otherwise, contains false (.F.).
Use the ISMEMOFETCHED( ) Function to determine if the memo field has been fetched.
Read/write.
FetchSizeN Contains the number of records fetched at a time from the remote tables. The default is 100 records. Setting FetchSize to –1 retrieves the complete result set, limited by the MaxRecords setting.
Note Note
Progressive fetching holds the connection until all rows are retrieved. Use caution coding with FetchSize if ShareConnection is True (.T.).

Read/write.
MaxRecordsN The maximum number of records fetched when result sets are returned. The default is – 1 (all rows are returned).
A value of 0 specifies that the view is executed but no results are fetched.
Read/write.
OfflineL Contains true (.T.) if the view is an offline view.
Read-only.
ParameterListC The Where clause parameters. The format for the parameters is ''ParameterName1, 'Type1'; ParameterName2, 'Type2'; ...'' where Type is a one of the following characters specifying the parameter type:
C – Character D – Date T – DateTime N – Numeric F – Floating B – Double I – Integer Y – Currency L - Logical
For example, ''MyParam1, 'C' '' specifies a single character type parameter named MyParam1.
For more information about creating parameterized views, see How to: Create Parameterized Views.
Read/write.
PreparedL Contains True (.T.) if SQL statements are prepared for subsequent Requery( ) function calls. Requery( ) is used to retrieve data again for a SQL view. See SqlPrepare( ) for additional information about preparing SQL statements. The default is false (.F.).
The rule text expression displayed when an error occurs when data is edited in a Browse or Edit window.
Read/write.
RuleExpressionC The row rule expression.
Read/write.
RuleTextC The rule text expression displayed when an error occurs when data is edited in a Browse or Edit window.
Read/write.
SendUpdatesL Contains true (.T.) if a SQL update query is sent to update remote tables; otherwise, contains false (.F.) (default).
Read/write.
ShareConnectionL Contains true (.T.) if a SQL update query is sent to update remote tables; otherwise, contains false (.F.) (default).
Read/write.
ShareTypeL Contains true (.T.) if the view can share its connection handle with other connections; otherwise, contains false (.F.).
Read/write.
SourceTypeN The view source. SourceType may assume the following values:
1 - The view uses local tables.
2 - The view uses remote tables.
Read-only.
SQLC The SQL statement executed when the view is opened.
Read/write.
TablesC A comma-delimited list of the names of the tables.
Read/write.
UpdateTypeN The update type. Valid values are:
1 or DB_Update (from Foxpro.h). The old data is updated with the new data (default).
2 or DB_DeleteInsert (from Foxpro.h). The old data is deleted and the new data is inserted.
Read/write.
UseMemoSizeN The minimum size (in bytes) for which result columns are returned in memo fields. For example, if the width of a column result is greater than the value of UseMemoSize, the column result is stored in a memo field. UseMemoSize may vary from 1 to 255; the default value is 255.
Read/write.
WhereTypeN The Where clause for updates to remote tables. WhereType may assume the following values:
1 or DB_KEY (from Foxpro.h). The Where clause used to update remote tables consists of only the primary fields specified with the KeyFieldList property.
2 or DB_KEYANDUPDATable (from Foxpro.h). The Where clause used to update remote tables consists of the primary fields specified with the KeyFieldList property and any updatable fields.
3 or DB_KEYANDMODIFIED (from Foxpro.h) (default). The Where clause used to update remote tables consists of the primary fields specified with the KeyFieldList property and any other fields that are modified.
4 or DB_KEYANDTIMESTAMP (from Foxpro.h). The Where clause used to update remote tables consists of the primary fields specified with the KeyFieldList property and a comparison of the time stamps.
For more information about the WhereType property, see Managing Updates by Using Views.
Read/write.
Examples
X#
 1Close Databases
 2Clear
 3Open Database (HOME(2) + 'Data\testdata')
 4* Displays the primary key field
 5cResults = DbGetProp("customer", "Table", "PrimaryKey")
 6=MessageBox(cResults)   // Displays    'cust_id'
 7* Displays comments for the field 'cust_id'
 8cResults = DbGetProp("customer.cust_id", "Field", "Comment")
 9IF LEN(ALLTRIM(cResults)) = 0
10=MessageBox("No Comment for this field." + CHR(13) + ;
11CHR (13) + "Use DbSetProp( ) to add comments.")
12ELSE
13=MessageBox("Cust_id field comments: " + cRESULTS)
14ENDIF
See Also