|
|
|
|
|
- Using a character string for the OLE DB provider
- If a failure occurs, the connection description is not stored
- Two connections are opened on the server
- Validity of connection
- Pseudo-connection to HFSQL Classic database
gpwOpenConnection (Function) In french: gpwOuvreConnexion
Not available with these kinds of connection
Opens a connection to a specific Client/Server database to manage User Groupware files in Client/Server mode. The connection remains open until the end of the application. gpwOpenConnection sets and opens a connection to the User Groupware data files. To use the same connection for all the data files of the application, use HChangeConnection. Then, gpwOpen is used to specify the location of data files for managing rights as well as the location of data files for identifying the users.
IF gpwOpenConnection("gpwCt", "Test", "PasswordMySQL", ...
"Apollon_server", "TEST", hNativeAccessMySQL) = False THEN
Error(HErrorInfo())
ELSE
nRes is int = gpwOpen()
IF nRes <> gpwOk THEN
SWITCH nRes
CASE gpwError:
Error("Error at initialization.", ErrorInfo())
CASE gpwUnknownUser:
Error("Unknown user.")
CASE gpwInvalidPassword:
Error("Invalid password")
END
END
HChangeConnection("*", "gpwCt")
Trace(HNbRec(CEDEX))
END
gpwInitAnalysis()
GPWUSER is Data Source
CNT_GPWu_HFCS is Connection
sPasswordGPWu is string = "PCSGPW2001"
CNT_GPWu_HFCS.Provider = hAccessHFClientServer
CNT_GPWu_HFCS.User = "UserHFServer"
CNT_GPWu_HFCS.Password = "PasswordHFServer"
CNT_GPWu_HFCS.Server = "HFServer"
CNT_GPWu_HFCS.Database = "GPWu"
CNT_GPWu_HFCS.CryptMethod = hCryptNo
gpwOpenConnection(CNT_GPWu_HFCS)
HChangeConnection(GPWUSER, CNT_GPWu_HFCS)
HPass(GPWUSER, sPasswordGPWu)
HCreationIfNotFound(GPWUSER)
HChangePassword(GPWUSER, "TEST")
CASE ERROR:
Error(HErrorInfo() + CR + ErrorInfo())
Syntax
Defining and opening a connection Hide the details
<Result> = gpwOpenConnection(<Connection name> , <User name> [, <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.
The effective connection opening is not performed by gpwOpenConnection. The function can return True even if the values passed as parameter are incorrect.
Use gpwOpen to specify the location of data files for managing rights as well as the location of data files for identifying the users. The directories must be specified in relation to the server directory.
<Connection name>: Character string Name of new connection to define and to open. This name must not be used by another connection (defined in the analysis, or with HOpenConnection or HDescribeConnection). <User name>: Character string Name of user who connects to the Client/Server database. This parameter is returned by the CtUserName property. <Password>: Optional character string Password defined for the connection to the Client/Server database (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. <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 is returned by the CtInitialCatalog property. <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 an HFSQL Classic database (single-user or multi-user) | hAccessHFClientServer | Connection to an HFSQL Client/Server database | hNativeAccessAS400 | Native AS/400 Access/Connector (optional module) | hNativeAccessDB2 | Native DB2 Access/Connector (optional module) | hNativeAccessInformix | Native Informix Access/Connector (optional module) | hNativeAccessMySQL | Native MySQL Access/Connector (optional module) | hNativeAccessOracle | Native Oracle Access/Connector (optional module) | hNativeAccessPostgreSQL | Native PostgreSQL Access/Connector (optional module) | hNativeAccessProgress | Native Progress access (optional module) | hNativeAccessSQLServer | Native SQL Server Access/Connector (optional module) | hNativeAccessSybase | Native Sybase Access/Connector (optional module) | hNativeAccessxBase | Native xBase Access/Connector | hODBC | OLE DB provider for ODBC. Used to access an ODBC 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 |
<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 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 OLE DB access used. These keywords must be indicated as follows: "<Keyword> = <Value>". <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: - 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 cursor can only move forward and be scrolled from the first to the last record. 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. |
Caution: some types of cursors may not be supported by all the OLE DB providers.
Opening a connection defined by a Connection variable Hide the details
<Result> = gpwOpenConnection(<Connection used>)
<Result>: Boolean - True if the operation was performed,
- False if a problem occurs. HErrorInfo is used to identify the error.
The effective connection opening is not performed by gpwOpenConnection. The function can return True even if the values passed as parameter are incorrect. Use gpwOpen to specify the location of data files for managing rights as well as the location of data files for identifying the users. The directories must be specified in relation to the server directory.
<Connection used>: Connection variable Name of the Connection variable to open. This name must not be used by another connection (defined in the analysis, or with HOpenConnection or HDescribeConnection). Remarks Using a character string for the OLE DB provider To easily find the character string that must be used to define the OLE DB provider, we recommend that you proceed as follows: - In the data model editor, display the description window of connections: on the "Analysis" tab, in the "Connection" group, click "Connections".
- Select the provider to use ("Connect via" combo box).
- The character string corresponding to the provider is displayed. This character string can be used in the syntax 2 instead of constants.
If a failure occurs, the connection description is not stored If the connection fails to open, the description of this connection is not validated. Therefore, it is possible to redefine a connection with the same name. For example, if the attempt to connect with the default password fails, you have the ability to perform a new attempt with another password. Two connections are opened on the server Two HFSQL contexts are used by the User Groupware. In the HFSQL Control Center, you will notice two connections for a single instance of the application. Validity of connection gpwOpenConnection behaves like HDescribeConnection: this function does not establish the connection immediately. gpwOpenConnection identifies the connection parameters that will be used thereafter to establish the connection. To validate this connection, you have the ability to call HOpenConnection before gpwOpenConnection with the same parameters. Therefore, the connection parameters will already be checked when gpwOpenConnection is called.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|