- Syntax 1: Using a character string for the OLE DB provider
- Syntax 1: Pseudo-connection to HFSQL Classic database
- Differences between HOpenConnection and HDescribeConnection
- Using the Native xBase Connector with non-Latin character sets
- UDL file
In french: HDécritConnexion
Not available with these kinds of connection
Describes a new connection to an external database. This connection is named. Specific parameters can be defined such as the management mode of cursors (if the accessed database allows it).
To open the connection, use HOpenConnection
. If the connection parameters described by HDescribeConnection
are incorrect, HOpenConnection
will return an error.
With HDescribeConnection, an Oracle table description imported into the analysis can be directly used by HFSQL Classic data files. Simply describe a temporary connection to an HFSQL Classic database and associate it with the file description from in the analysis. See the Examples for more details.
Describing a connection through programming Hide the details
<Result> = HDescribeConnection(<Connection> , <User> [, <Password>] , <Data source> , <Database> , <OLE DB provider or Native Connector> [, <Access> [, <Extended information>]] , <Additional options>)
- True if the operation was performed,
- False if a problem occurs. HErrorInfo is used to identify the error.
To establish this connection, use HOpenConnection
(this function will return an error if the connection parameters are incorrect).
<Connection>: Character string
Name of new connection to define.
If this name is already used by an existing connection, the former connection is replaced with the new one. The former connection (as well as the data files that used it) are automatically closed.
<User>: Character string
Username used for the database. This parameter is returned by the CtUserName property.
<Password>: Optional character string
Connection password (if this password exists). If no password is required, use an empty string ("") or the NULL keyword.
<Data source>: Character string
Full path of the data source. The connection will be created and opened for this data source. This parameter is returned by the CtDatabase property.
XML: This parameter corresponds to the name of XML file.
This parameter corresponds to the server name. The port number used by the HFSQL server can be specified. The port 4900 will be used by default. If the port number of the HFSQL server is different, use the following notation:
<Computer name>: <Port number>
For a use via Internet, the ports must be managed by Firewall. For more details, see Managing ports
.You have the ability to specify an IPv6 address by writing the IPv6 address between square brackets. In this case, the port number must be specified after the closing square bracket. For example: [0154:2145:2155::5554]:4900.
<Database>: Character string
Name of database that will be used on the data source, empty string ("") if no name must be specified. This parameter can be used if the data source allows you to specify the database that must be used.
For example, on SQL Server, the "Master" database is the default database but other databases can be handled ("dbo" for example).
To specify that the access is performed on a file found in the "dbo" database (that is not the default database), <Database> must correspond to "dbo".
<OLE DB provider or Native Connector>: Character string or constant
- Name of OLE DB provider used. To easily retrieve the string to use, select "Connection" in the data model editor (see the Notes).
- one of the following constants:
|hAccessHF7||Pseudo-connection to HFSQL Classic database|
|hAccessHFClientServer||Native Connector to an HFSQL Client/Server database.|
|hNativeAccessAS400||Native AS/400 Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessDB2||Native DB2 Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessInformix||Native Informix Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessMariaDB||Native MariaDB Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessMySQL||Native MySQL Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessOracle||Native Oracle Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessOracleLite||Native Oracle Connector (optional module of WINDEV Mobile)|
|hNativeAccessPostgreSQL||Native PostgreSQL Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessProgress||Native Progress Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessSQLAzure||Native SQL Azure Connector (optional module of WINDEV/WEBDEV, provided with Native SQL Server Connector)|
|hNativeAccessSQLite||Native SQLite Connector (provided with WINDEV/WEBDEV)|
|hNativeAccessSQLServer||Native SQL Server Connector (optional module of WINDEV/WEBDEV).|
The former Native Connector is used by default. To use the new Native SQL Server Connector, use the H.SQLServerMode variable.
|hNativeAccessSQLServerMobile||Native SQL Server Mobile Connector (optional module of WINDEV Mobile)|
|hNativeAccessSybase||Native Sybase Connector (optional module of WINDEV/WEBDEV)|
|hNativeAccessXBase||Native xBase Connector (included with WINDEV/WEBDEV)|
|hNativeAccessXML||Native XML Connector (included with WINDEV/WEBDEV)|
|hODBC||OLE DB provider for ODBC (used to access an ODBC data source declared in the ODBC data sources of Windows)|
|hOledbAccess97||OLE DB provider for Access 97|
|hOledbAccess2000||OLE DB provider for Access 2000|
|hOledbDBase5||OLE DB provider for dBase 5|
|hOledbExcel97||OLE DB provider for Excel 97|
|hOledbExcel2000||OLE DB provider for Excel 2000|
|hOledbLotus4||OLE DB provider for Lotus 4|
|hOledbOracle||OLE DB provider for Oracle|
|hOledbSQLServer||OLE DB provider for SQL Server|
Caution: To use an OLE DB connection, you must:
- install MDAC version 2.6 or later (setup performed by WINDEV/WEBDEV and when creating the client version)
- install the OLE DB provider corresponding to the database used.
This parameter is returned by the CtOLEDBProvider property.
<Access>: Optional constant
Configures the type of access to the database.
|hORead||The database can be accessed in read-only. You only have the ability to read the records. No record can be added or deleted.|
|The database can be accessed in read/write. You have the ability to read the records and to write new records.|
This parameter is returned by the CtAccess property.
<Extended information>: Optional character string
Optional information inserted into the string for connecting to the database. If specific keywords are recognized, the corresponding information is extracted from the connection string. The rest of the connection string is sent to the database. Then, the extracted parameters are processed by the Native Connector or by the OLE DB connector used.
These keywords must be indicated as follows: "<Keyword> = <Value>;".
You can for example specify "Trusted_Connection=YES" in order to use a connection with authentication via the NT login.
The keywords recognized by OLE DB and the Native Connectors are presented in the Optional connection information
Example of string to use:
"WD Cache Size = 10000; Server Port=3306;"
Keywords recognized for the access by HFSQL Client/Server:
|COMPRESSION||Enables or disables the compression of data exchanged between Client and Server. This keyword can correspond to:|
- TRUE to enable the data compression.
- FALSE to disable the data compression.
|DB_EXIST||Checks the existence of the database. If the specified database does not exist, HDescribeConnection returns False.|
|ENCRYPTION||Enables the encryption of data exchanged between Client and Server. This keyword can take two values:|
- RC5_16 for a RC5 encryption (16 rounds).
This parameter is returned by the CtExtendedInfo
<Additional options>: Constant
If this parameter is not specified, the HFSQL engine automatically defines the best parameters to use according to the database accessed and to the OLE DB provider used.
To force some parameters, you have the ability to combine the following constants:
- Location of cursors
|hClientCursor||Cursor managed by MDAC. Offers more features than a server cursor. A client cursor must necessarily be a static cursor.|
|hServerCursor||Cursor managed by the database. This cursor can easily apply the changes performed by the other users to the data.|
- Type of cursor
|hDynamicCursor||Cursor offering a lot of features but consuming a lot of memory. This cursor allows all types of moves. It allows you to access all the modifications, additions and deletions performed by the other users.|
|hForwardOnlyCursor||Fast cursor consuming little memory. The move is performed from the first record to the last one. The data modified by the other users is not visible.|
|hOpenKeysetCursor||Cursor that handles a fixed set of records. Only the keys corresponding to the record are stored and not the records (consumes less memory). The deleted records can no longer be accessed. Modifications performed by other users are visible (but records added are not).|
|hStaticCursor||Makes a copy of all query records in memory (high memory usage). All types of moves are allowed.|
- Lock mode
|hOptimisticCursor||The record is locked when it is updated|
|hPessimisticCursor||The record is locked as soon as it goes into edit mode to be modified.|
|hReadOnlyCursor||The set of records cannot be modified.|
Caution: some types of cursors may not be supported by all the OLE DB providers.
Syntax 1: Pseudo-connection to HFSQL Classic database
OLE DB data files or native data files are described in the data model editor. To handle these descriptions through programming with an HFSQL database, simply specify the hAccessHF7 constant as provider name.
Then, this connection can be assigned to the data files affected by HChangeConnection
The data files in HFSQL format corresponding to the description of the OLE DB or native files will be created (if necessary) in the directory defined by <Data source>. By default, these data files are empty when they are created.
Differences between HOpenConnection and HDescribeConnection
: To open a connection at the start of the application and close it at the end, use HOpenConnection
. To use this connection when handling data files or tables, simply change this connection with HChangeConnection
HOpenConnection(MyConnection, params) // open the connection
Method 2: To describe a connection through programming and to automatically open it when opening the data file, you must:
- describe the connection with HDescribeConnection.
- associate this connection with the desired data file description using HChangeConnection. The connection will only be opened the first time the data file is accessed.
This solution can be useful when an application handles both HFSQL data files and Oracle data files. For example, if the application uses a single Oracle file, in a specific process, the connection to the Oracle database will only be made if necessary.
If the first solution is chosen for the same type of application, the connection (that may take quite a long time) will be established whenever the application is started.
HReadFirst(AFile) // Open the connection
HClose(AFile) // Close the connection
Using the Native xBase Connector with non-Latin character sets
To use the Native xBase Connector with non-Latin character sets, a standard OEM/ANSI conversion must be performed by the Native Connector. To do so, the following string must be specified in the extended information:
- In the initialization code of the project, add the code used to modify the character set:
- Create an xBase connection:
HDescribeConnection("CntxBase", "", "", fExeDir(), "", hNativeAccessXBase, hOReadWrite, ...
To create a UDL file:
- Create a text file whose extension is "UDL".
- Double-click this file. The window for the properties of the data links is opened.
- Configure the connection.
- Run the test of the connection.
- Validate ("OK" button). The UDL file can now be used.
Business / UI classification: Business Logic
This page is also available for…