ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / Managing HFSQL Client/Server
  • Overview
  • Defining the connections from the data model editor
  • Encrypting a connection
  • Defining the connections programmatically
  • Defining a connection with HDescribeConnection or HOpenConnection
  • Defining a connection via the Connection type
  • Allowing a WINDEV application to use an HFSQL Client/Server database or an HFSQL Classic database
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Client/Server: Connecting client computers to the server
HFSQL Client/ServerAvailable only with this kind of connection
Overview
In order for the application to be able to handle the data files found on the HFSQL server, the connection that will be used by the application must be defined in the project. The connection can be defined:
  • in the data model editor.
  • through programming.
You also have the ability to allow an application to use an HFSQL Client/Server database or an HFSQL Classic database.
The data files accessed by an HFSQL server are accessible via this server only. They cannot be directly accessed by another application especially via the HFSQL Classic engine. A connection to the server is required to access these data files.
Note Multiple connections can be defined if the application uses several databases or servers.
Defining the connections from the data model editor
To define a connection from the data model editor:
  1. On the "Analysis" tab, in the "Connection" group, click "New connection". The wizard for defining a new connection starts.
  2. Keep "HFSQL Client/Server" and go to the next step of the wizard.
  3. In the different steps of the wizard, enter the requested information:
    • server name,
    • number of the network port,
    • name and password of the user,
    • database,
    • name and caption of the connection.
  4. Finish the wizard.
    A dialog box allows you to associate the data files with this new connection. Accept.
  5. Select the data files to associate and validate. The existing data files can be directly copied onto the HFSQL server. This operation can be performed later if necessary.
  6. Display the list of connections: under the "Analysis" pane, in the "Connection" group, click on "Connections".
    • Test this new connection if necessary: click on the "Test" button.
    • The different tabs are used to view and modify the characteristics of the connections:
      • Tab "Properties": connection characteristics defined in the wizard (name, label, type, ...)
      • Tab "Advanced": Connection port number, connection data compression and encryption options.
        If the data files that use the connection are encrypted, the connection should be encrypted as well.
      • Tab "Used by": List of data files using the connection.
  7. Close the window of defined connections.
At runtime, the connection associated with the data file used will be automatically opened during the first access to this data file.
Data files associated with an "HFSQL Client/Server" connection are automatically transformed into "HFSQL Client/Server" data files.
To identify them, an indication "HFSQL/CS" appears at the bottom of the graphic description of these data files. Furthermore, the color associated with this area becomes orange:

Encrypting a connection

To encrypt a connection:
  1. Display the connection description: under the "Analysis" pane, in the "Connection" group, click on "Connections".
  2. Select the connection to encrypt.
  3. Go to the "Advanced" tab.
  4. Select encryption mode: Fast or RC5 (16 loops).
  5. Validate.
Note: If the data files using the connection are encrypted, it is advisable to encrypt the connection as well.
Defining the connections programmatically
Several methods can be used to define a connection through programming:

Defining a connection with HDescribeConnection or HOpenConnection

To define a connection with HDescribeConnection or HOpenConnection:
  1. Define the connection with HDescribeConnection or HOpenConnection.
    The <Data Source> parameter must correspond to the name or IP address of the server that will be used. If the network port to use differs from the default port (port 4900), <Data Source> must have the following format:
    "<NameOrIPAddressOfServer>:<PortNumber>".
    The <OLEDB Provider or Native Connector> parameter must correspond to the hAccessHFClientServer constant.
    For example:
    HDescribeConnection("MaConnexion", "Julie", "MotDePasse", "MonServeurHF", ...
    			"MaBaseDeDonnées", hAccessHFClientServer, hORead)

    or
    HOpenConnection("ConnexionServeur", "Stephane", "", "ServeurDonnées:5400", ...
    			"MesDonnées", hAccessHFClientServer)
  2. Open the connection using the HOpenConnection function.
    This step is not required if the connection was defined and opened by HOpenConnection beforehand.
  3. Associate the connection with the different data files using HChangeConnection.
    For example:
    HChangeConnection(Client, "MaConnexion")

    or, to associate all analysis data files with the connection:
    HChangeConnection("*", "ConnexionServeur")
Note: To encrypt the connection, simply specify specific extended information ("ENCRYPTION = FAST" or "ENCRYPTION = RC5_16". For more details, see the documentation about HDescribeConnection or HOpenConnection.

Defining a connection via the Connection type

To define a connection using the Connection type:
  1. Define the connection using the Connection type and its properties.
    For example:
    MaConnexion is Connection
    // Description de la connexion
    MaConnexion.User = "USER"
    MaConnexion.MotDePasse = "PASSWORD"
    MaConnexion.Server = "MONSERVEUR" 
    MaConnexion.Database = "Base de données"
    MaConnexion.Provider = hAccessHFClientServer
    MaConnexion.Access = hOReadWrite
    MaConnexion.ExtendedInfo = "Infos étendues"
    MaConnexion.CursorOptions = hClientCursor
  2. Open the connection using the HOpenConnection function.
    For example:
    MaConnexion is Connection
    // Description de la connexion
    MaConnexion.User = "USER"
    MaConnexion.MotDePasse = "PASSWORD"
    MaConnexion.Server = "MONSERVEUR" 
    MaConnexion.Database = "Base de données"
    MaConnexion.Provider = hAccessHFClientServer
    MaConnexion.Access = hOReadWrite
    MaConnexion.ExtendedInfo = "Infos étendues"
    MaConnexion.CursorOptions = hClientCursor
Note To encrypt the connection, simply use the Encryption property on the connection.
For example:
MaConnexion is Connection
// Description de la connexion
MaConnexion.User = "USER"
MaConnexion.MotDePasse = "PASSWORD"
MaConnexion.Server = "MONSERVEUR" 
MaConnexion.Database = "Base de données"
MaConnexion.Encryption = hEncryptionRC5_16
MaConnexion.Provider = hAccessHFClientServer
MaConnexion.Access = hOReadWrite
MaConnexion.ExtendedInfo = "Infos étendues"
HOpenConnection(MaConnexion)
Allowing a WINDEV application to use an HFSQL Client/Server database or an HFSQL Classic database
Two WLanguage functions allow you to use any database chosen at runtime. Regardless of the type of data files specified in the analysis.
This can be very useful for an application installed on a laptop computer:
  • connected to the network, the application uses the HFSQL Client/Server database,
  • disconnected, the application uses a local copy of the database.
The code that should be used (at the beginning of project, before using the data files) is as follows:
AdresseServeur is string = "198.168.1.120"

IF Ping(AdresseServeur) THEN
	// Le serveur est accessible, connexion HF C/S
	HOpenConnection("ConnexionHFCS", "admin", "", AdresseServeur, "CRM", hAccessHFClientServer)
    	HChangeConnection("*", "ConnexionHFCS")
    	Info("Mode connecté à la base réseau.")
ELSE
   	// Le serveur ne répond pas, utilisation de la base HF locale
   	HOpenConnection("ConnexionHFLocale", "", "", "C:\Répertoire Données\", "", hAccessHF7)
   	HChangeConnection("*", "ConnexionHFLocale")
   	Info("Mode déconnecté, vous utilisez vos données en local.")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/20/2025

Send a report | Local help