|
|
|
|
|
- Syntax 1: Open a predefined connection: automatic connection management
- Syntax 2: Using a character string for the OLE DB provider
- Syntax 2 and 3: If a failure occurs, the connection description is not kept
- Pseudo-connection to HFSQL Classic database
- Differences between HOpenConnection and HDescribeConnection
- UDL file (file for describing an OLE DB connection)
- Oracle Native Connector: external authentication management
- Limitations
HOpenConnection (Function) In french: HOuvreConnexion
Not available with this kind of connection
Opens a connection to a specific database. The connection remains opened until the call to HCloseConnection. HOpenConnection is used to: - open a preset connection.
- define and open a connection. Then, this connection must be assigned to a data file with HChangeConnection.
- define and open a connection by using a connection string. This syntax can be used with some OLE DB providers who have specific ADO connecting strings.
This option is not available.
- open a connection defined by a Connection variable.
Caution: The order of use of functions for connecting to an HFSQL Client/Server database is important.. For more details, see Optimizing the connection times to the HFSQL Client/Server databases. Syntax
Opening a preset connection Hide the details
<Result> = HOpenConnection(<Connection>)
<Result>: Boolean - True if the operation was performed,
- False if a problem occurred (during a connection described through programming, some parameters used in HDescribeConnection may be incorrect for example).
<Connection>: Character string or Connection variable Connection to a database. This connection corresponds to: - the name of the connection defined in the data model editor,
- the name of the connection defined by HDescribeConnection. The connection description must be known when running the function.
- the name of a variable of type Connection.
Defining and opening a connection Hide the details
<Result> = HOpenConnection(<New connection> , <User> [, <Password>] , <Data source> [, <Database>] , <OLE DB provider or Native Connector> [, <Access> [, <Extended information> [, <Additional options>]]])
<Result>: Boolean - True if the operation was performed,
- False if a problem occurs. HErrorInfo is used to identify the error. To assign this connection to a file, use HChangeConnection. The connection description will be deleted when closing the connection.
<New connection>: Character string or Connection variable Name of new connection to define and to open. This name must not be used by another connection (defined in the analysis, or by HOpenConnection or HDescribeConnection).This parameter corresponds to the Name property used on a variable of type Connection. <User>: Character string Username used for the database. This parameter can be modified and retrieved using the User property on a variable of type Connection. <Password>: Optional character string Connection password (if this password exists). If no password is required, use an empty string ("") or the NULL keyword. This parameter can be modified using the Password property on a variable of type Connection. <Data source>: Character string Full path of the data source. The connection will be created and opened for this data source.This parameter can be retrieved and modified using the Source property (or Server) on a variable of type Connection.
<Database>: Optional character string Name of database that will be used on the data source. If this parameter is not required, use an empty string ("").This parameter can be retrieved and modified using the Database property on a variable of type Connection. In the case of a database divided into schemas, the name of the schema in the database will be specified by HChangeName. This database will be automatically created if it does not exist. <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).
or - 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 the 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 (provided with WINDEV/WEBDEV). | hNativeAccessXML | Native XML Connector (provided 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. | hOledbAccess2007 | OLE DB provider for Access 2007. | hOledbAccess2010 | OLE DB provider for Access 2010. | hOledbDBase5 | OLE DB provider for dBase 5. | hOledbExcel97 | OLE DB provider for Excel 97. | hOledbExcel2000 | OLE DB provider for Excel 2000. | hOledbExcel2007 | OLE DB provider for Excel 2007. | hOledbLotus4 | OLE DB provider for Lotus 4. | hOledbOracle | OLE DB provider for Oracle. | hOledbSQLServer | OLE DB provider for SQL Server |
This parameter can be retrieved and modified using the Provider property on a variable of type Connection.
<Access>: Optional constant Configures the type of access to the database. | | hORead | The database can be accessed in read-only. It is only possible to read records. It is not possible to add or remove records. | hOReadWrite (default value) | The database can be accessed in read/write. It is possible to read and write new records. | This parameter can be retrieved and modified using the Access property on a variable of type Connection. <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: "<Mot-clé> = <Valeur>;".You can for example specify "Trusted_Connection=YES" in order to use a connection with authentication via the NT login.
<Additional options>: Optional 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. By default, this parameter corresponds to the following combination of constants: hServerCursor + hOpenKeysetCursor + hOptimisticCursor However, these parameters can differ according to the information returned by the database. To force some parameters, you have the ability to combine the following constants: - Cursor location
| | hClientCursor | Cursor managed by MDAC. Generally, it offers more features than a server-side cursor. A client-side cursor is always static. | hServerCursor | Cursor managed by the database. This cursor can easily reflect changes made to data by other users. |
- Cursor type
| | hDynamicCursor | This cursor offers many features, but consumes a lot of memory. This cursor supports all types of scrolling. You can access all insert, update and delete operations made by other users. | hForwardOnlyCursor | This cursor is fast and consumes little memory. The move is performed from the first record to the last one. Changes made by other users are not visible. | hOpenKeysetCursor | This cursor handles a fixed set of records. Only the key of each record is stored and not the actual record (consumes less memory). Deleted records cannot be accessed. Changes made by other users are visible (but added records are not). | hStaticCursor | Makes a copy of all query records in memory (high memory consumption). All types of scrolling are supported. |
- Lock mode
| | hOptimisticCursor | The record is locked when it is updated | hPessimisticCursor | The record is locked as soon as it is edited. | hReadOnlyCursor | The record set manipulated cannot be modified. |
Please note: not all OLE DB providers support all cursor types.This parameter can be retrieved and modified using the CursorOptions property. Remarks Differences between HOpenConnection and HDescribeConnection Method 1: To open a connection at the beginning of the application and close it at the end, use the HOpenConnection function.. To use this connection when handling data files or tables, simply change this connection with HChangeConnection. HOpenConnection(MaConnexion, params)
HChangeConnection(UnFichier, MaConnexion)
Method 2: To programmatically describe a connection and open it automatically when the file is opened, simply: - 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. Example: HDescribeConnection(MaConnexion, params)
HChangeConnection(UnFichier, MaConnexion)
...
HReadFirst(unFichier)
...
HClose(UnFichier)
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|