PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Using a 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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
gpwOpenConnection (Function)
In french: gpwOuvreConnexion
ODBCHFSQLNot available with these kinds of connection
Opens a connection to a specific Client/Server database to manage the files of user groupware in Client/Server mode. The connection remains opened until the end of application.
The gpwOpenConnection function allows you to define and open a connection for user groupware data files. To use the same connection on all the data files of the application, just use the 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.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Example
// Utilisation des fichiers du groupware utilisateur avec une base de données MySQL
IF gpwOpenConnection("gpwCx", "Test", "MotPasseMySQL", ...
"Serveur_apollon", "TEST", hNativeAccessMySQL) = False THEN
Error(ErrorInfo())
ELSE
// Les fichiers de données du groupware utilisateur
// sont automatiquement créés
// si l'utilisateur a les droits sur MySQL.
nRes is int = gpwOpen()
// Si le login a échoué
IF nRes <> gpwOk THEN
SWITCH nRes
CASE gpwError:
Error("Erreur à l'initialisation.", ErrorInfo())
CASE gpwUnknownUser:
Error("Utilisateur inconnu.")
CASE gpwInvalidPassword:
Error("Mot de passe invalide.")
END
END
// Utilisation de la même connexion pour tous les fichiers de données
HChangeConnection("*", "gpwCx")
Trace(HNbRec(CEDEX))
END
// Changer le mot de passe des fichiers de données du groupware utilisateur
// par programmation
// Exemple avec le fichier de données GPWUTILISATEUR
gpwInitAnalysis()
GPWUTILISATEUR is Data Source
CNX_GPWu_HFCS is Connection
sMotDePasseGPWu is string = "PCSGPW2001"
 
// Paramètres de la connexion
CNX_GPWu_HFCS.Provider = hAccessHFClientServer
CNX_GPWu_HFCS.User = "UserServerHf"
CNX_GPWu_HFCS.MotDePasse = "MotDePasseServerHF"
CNX_GPWu_HFCS.Server = "ServeurHF"
CNX_GPWu_HFCS.Database = "GPWu"
CNX_GPWu_HFCS.CryptMethod = hEncryptionNO
 
// Ouverture de la connexion
gpwOpenConnection(CNX_GPWu_HFCS)
HChangeConnection(GPWUTILISATEUR, CNX_GPWu_HFCS)
HPass(GPWUTILISATEUR, sMotDePasseGPWu)
HCreationIfNotFound(GPWUTILISATEUR)
HChangePassword(GPWUTILISATEUR, "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 occurred. 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 already be used by another connection (connection defined in the analysis, or defined with the HOpenConnection or HDescribeConnection function).
<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 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:
    hAccessHF7Pseudo-connection to an HFSQL Classic database (single-user or multi-user)
    hAccessHFClientServerConnection to an HFSQL Client/Server database
    hNativeAccessAS400Native AS/400 Access/Connector (optional module)
    hNativeAccessDB2Native DB2 Access/Connector (optional module)
    hNativeAccessInformixNative Informix Access/Connector (optional module)
    hNativeAccessMySQLNative MySQL Access/Connector (optional module)
    hNativeAccessOracleNative Oracle Access/Connector (optional module)
    hNativeAccessPostgreSQLNative PostgreSQL Access/Connector (optional module)
    hNativeAccessProgressNative Progress access (optional module)
    hNativeAccessSQLServerNative SQL Server Access/Connector (optional module)
    hNativeAccessSybaseNative Sybase Access/Connector (optional module)
    hNativeAccessxBaseNative xBase Access/Connector
    hODBCOLE DB provider for ODBC.
    Used to access an ODBC source declared in the ODBC data sources of Windows.
    hOledbAccess97OLE DB provider for Access 97
    hOledbAccess2000OLE DB provider for Access 2000
    hOledbDBase5OLE DB provider for dBase 5
    hOledbExcel2000OLE DB provider for Excel 2000
    hOledbExcel97OLE DB provider for Excel 97
    hOledbLotus4OLE DB provider for Lotus 4
    hOledbOracleOLE DB provider for Oracle
    hOledbSQLServerOLE DB provider for SQL Server
OLE DB Caution: To use an OLE DB connection, you must:
  • install MDAC version 2.6 or later (setup performed by WINDEV or WEBDEV and when creating the setup program)
  • 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.
hOReadWrite
(default value)
The database can be accessed in read/write. You have the ability to read the records and to write new records.
hOReadThe database can be accessed in read-only. You only have the ability to read the records. No record can be added or deleted.

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. The extracted parameters are then processed specifically by the Native Connector or OLE DB access used.
These keywords must be indicated as follows: "<Keyword> = <Value>".
Native Connectors (Native Accesses) Recognized keywords for Native Connector MySQL:
Server PortSee the documentation about MySQL (keyword = 'mysql_real_connect') for more details.
Unix Socket
Client Flag


OLE DB Keywords recognized for the access by an OLE DB provider:
WD Command TimeoutDefines the maximum timeout (in seconds) for running a command (command timeout). Does not work on the Native Connector MySQL.
WD Connect TimeoutDefines the maximum timeout (in seconds) for establishing the connection (connection timeout). Does not work on the Native Connector MySQL.


HFSQL Client/Server Keywords recognized for the access by HFSQL Client/Server:
CRYPTAGEEnables the encryption of data exchanged between Client and Server. This keyword can take two values:
  • FAST
  • RC5_16 for a RC5 encryption (16 rounds).
This parameter can be retrieved through the Property 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
    hClientCursorCursor managed by MDAC. Offers more features than a server cursor. A client cursor must necessarily be a static cursor.
    hServerCursorCursor managed by the database. This cursor can easily apply the changes performed by the other users to the data.
  • Type of cursor
    hDynamicCursorCursor 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.
    hForwardOnlyCursorFast 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.
    hOpenKeysetCursorCursor 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).
    hStaticCursorMakes a copy of all query records in memory (consumes a lot of memory). All types of moves are allowed.
  • Lock mode
    hReadOnlyCursorThe set of records cannot be modified.
    hOptimisticCursorThe record is locked when it is updated
    hPessimisticCursorThe record is locked as soon as it goes into edit mode to be modified.
Caution: some types of cursors may not be supported by all the OLE DB providers.
This parameter is returned by the CtCursorOptions property.

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 occurred. 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 already be used by another connection (connection defined in the analysis, or defined with the HOpenConnection or HDescribeConnection function).
Remarks

Using a 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:
  1. In the data model editor, display the description window of connections: on the "Analysis" tab, in the "Connection" group, click "Connections".
  2. Select the provider to use ("Connect via" combo box).
  3. 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. It is therefore Normal to observe in the HFSQL Control Center two connections for a single instance of the application.

Validity of connection

gpwOpenConnection behaves like HDescribeConnection: this function does not establish the connection immediately.
The gpwOpenConnection function notes the connection parameters to be used when connecting later.
To validate this connection, you have the ability to call HOpenConnection before gpwOpenConnection with the same parameters. Thus, the connection parameters will already be checked when the gpwOpenConnectionfunction is called.
WINDEVWindowsLinux

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 with an HFSQL Classic database, <OLE DB provider or Native Connector> must correspond to the hAccessHF7 constant.
The data files in HFSQL Classic format corresponding to the description of the OLE DB or native files will be created (if necessary) in the directory defined by <Data source>.
Component: wd270gpu.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment