|
|
|
|
|
- Syntax 1: Opening a preset connection: automatic management of connections
- Syntax 2: Using a character string for the OLE DB provider
- Syntax 2 and 3: If a failure occurs, the connection description is not stored
- Pseudo-connection to HFSQL Classic database
- Differences between HOpenConnection and HDescribeConnection
- UDL file (file for describing an OLE DB connection)
- Native Oracle Connector: managing the external authentication
- 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.
Access by JDBC: This option is not available. - open a connection defined by a Connection variable.
Caution: The order in which the functions for connecting to an HFSQL Client/Server database are called 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, supplied 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 (provided with WINDEV/WEBDEV). | hNativeAccessXML | Native XML Connector (supplied 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 |
The available constants are as follows: | | hAccessHF7 | Pseudo-connection to an HFSQL database | hAccessHFClientServer | Connection to an HFSQL Client/Server database. | hAccessJDBCMySQL | Access to MySQL database via JDBC. | hAccessJDBCSQLite | Access to SQLite database via JDBC. | hAccessJDBCSQLServer | Access to SQL Server database via JDBC. | 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. You can only read records. No record can be added or deleted. | hOReadWrite (default value) | The database can be accessed in read/write. You can 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: "<Keyword> = <Value>;".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: - 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.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 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)
HChangeConnection(AFile, MyConnection)
Method 2: To describe a connection through programming and to automatically open it when the file is opened, 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. Example:
HDescribeConnection(MyConnection, params)
HChangeConnection(AFile, MyConnection)
...
HReadFirst(AFile)
...
HClose(AFile)
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|