This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Syntax 1: Opening a preset connection: automatic management of connections
  • Syntax 2: Using a 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
  • Native Oracle Connector: managing the external authentication
  • Limitations
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
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.

  • 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.
Universal Windows 10 AppHFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)
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

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).
HErrorInfo is used to identify the error.
<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 nom 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.
HFSQL Client/Server This parameter corresponds to the server name. The port number used by the HFSQL server can be specified. The port 4900 will be used by default. If the port number of the HFSQL server is different, use the following notation:
<Computer name>: <Port number>
Example: "ComputerName:4901".
For a use via Internet, the ports must be managed by Firewall. For more details, see Port Management. You have the ability to specify an IPv6 address by writing the IPv6 address between square brackets. In this case, the port number must be specified after the closing square bracket. For example: [0154:2145:2155::5554]:4900.
AndroidAndroid Widget For a connection to an HFSQL Client/Server database on the development computer from an Android emulator, you must use the IP address with the server port. Example: "".
For a connection to an HFSQL Client/Server database on the network of the development computer from an Android emulator, you must use the full name of the server with the domain. However, with the WINDEV Mobile simulator, the computer name without domain may be sufficient. Example: "".
For a connection to an SQLite database: full path of the file containing the SQLite database on the Android device.
Example : /sdcard/bdd/MyDatabase.db
If the parameter corresponds to an empty string (""), the file containing the database data will be created in the "databases" directory of application and its name will be identical to the application name followed by the ".db" extension.
<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.
Native Connectors (Native Accesses) DB2: This parameter is not required.
<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).
  • one of the following constants:
    hAccessHF7Pseudo-connection to HFSQL Classic database.
    hAccessHFClientServerNative Connector to an HFSQL Client/Server database.
    hNativeAccessAS400Native AS/400 Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessDB2Native DB2 Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessInformixNative Informix Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessMariaDBNative MariaDB Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessMySQLNative MySQL Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessOracleNative Oracle Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessOracleLiteNative Oracle Connector (optional module of WINDEV Mobile).
    hNativeAccessPostgreSQLNative PostgreSQL Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessProgressNative Progress Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessSQLAzureNative SQL Azure Connector (optional module of WINDEV/WEBDEV, supplied with Native SQL Server Connector).
    hNativeAccessSQLiteNative SQLite Connector (provided with WINDEV/WEBDEV).
    hNativeAccessSQLServerNative 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.
    hNativeAccessSQLServerMobileNative SQL Server Mobile Connector (optional module of WINDEV Mobile).
    hNativeAccessSybaseNative Sybase Connector (optional module of WINDEV/WEBDEV).
    hNativeAccessXBaseNative xBase Connector (provided with WINDEV/WEBDEV).
    hNativeAccessXMLNative XML Connector (supplied with WINDEV/WEBDEV).
    hODBCOLE DB provider for ODBC (used to access an ODBC data source declared in the ODBC data sources of Windows).
    hOledbAccess97OLE DB provider for Access 97.
    hOledbAccess2000OLE DB provider for Access 2000.
    hOledbAccess2007OLE DB provider for Access 2007.
    hOledbAccess2010OLE DB provider for Access 2010.
    hOledbDBase5OLE DB provider for dBase 5.
    hOledbExcel97OLE DB provider for Excel 97.
    hOledbExcel2000OLE DB provider for Excel 2000.
    hOledbExcel2007OLE DB provider for Excel 2007.
    hOledbLotus4OLE DB provider for Lotus 4.
    hOledbOracleOLE DB provider for Oracle.
    hOledbSQLServerOLE DB provider for SQL Server

    AndroidAndroid Widget The available constants are as follows:
    hNativeAccessSQLiteNative SQLite Connector for Android applications.

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.
hOReadThe database can be accessed in read-only. You can only read records. No record can be added or deleted.
HFSQL Client/Server This constant is ignored.
(default value)
The database can be accessed in read/write. You can read and write new records.
This parameter can be known and modified thanks to the Property Access used on an Variable 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.
Native Connectors (Native Accesses) The keywords recognized by OLE DB and the Native Connectors are displayed on Optional connection information.
Example of string to use:
"WD Cache Size = 10000; Server Port=3306;"
HFSQL Client/Server Recognized keywords for the access via HFSQL Client/Server:
COMPRESSIONEnables or disables the compression of data exchanged between Client and Server. This keyword can correspond to:
  • TRUE to enable the data compression.
  • FALSE to disable the data compression.
DB_EXISTChecks the existence of the database. If the specified database does not exist, this database is not created and HOpenConnection returns False.
ENCRYPTIONEnables the encryption of data exchanged between Client and Server. This keyword can take two values:
  • FAST
  • RC5_16 to use 16-round RC5 encryption.
  • New in version 28
    AES128 to use 128-bit AES encryption with the OFB mode of operation.
  • New in version 28
    AES192 to use 192-bit AES encryption with the OFB mode of operation.
  • New in version 28
    AES256 to use 256-bit AES encryption with the OFB mode of operation.

This parameter can be retrieved and modified using the ExtendedInfo property.
<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
    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 (high memory usage). All types of moves are allowed.
  • Lock mode
    hOptimisticCursorThe record is locked when it is updated
    hPessimisticCursorThe record is locked as soon as it goes into edit mode to be modified.
    hReadOnlyCursorThe 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.
Universal Windows 10 AppiPhone/iPadHFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

Syntax 1: Opening a preset connection: automatic management of connections

  • The connection associated with a data file is automatically opened when the data file is opened. The connection is closed when the last data file that uses this connection is closed.
  • Any connection opened by HOpenConnection remains open even if no data file uses it.
  • If the application opens and closes data files many times in a row, the automatic management of connections will open/close connections many times, slowing down the application. In this case, it is recommended to use HOpenConnection to keep the connection open.
HFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

Syntax 2: 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 analysis editor, create an HFSQL Client/Server connection, for example.
  2. In the connection description screen, select the provider to be used (in "Connection by").
  3. The character string corresponding to the provider is displayed. This character string can be used in the syntax 2 instead of constants.
Using a String for the OLE DB Provider
HFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

Syntax 2 and 3: If a failure occurs, the connection description is not stored

If the connection fails to open, the description of this connection is not validated. This allows you 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.
iPhone/iPadHFSQL Classic

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, simply specify the hAccessHF7 constant as provider name.
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>.

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(MaConnexion, params) // Ouverture de la connexion
HChangeConnection(UnFichier, MaConnexion)
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.
HDescribeConnection(MaConnexion, params)
HChangeConnection(UnFichier, MaConnexion)
HReadFirst(unFichier) // Ouverture de la connexion
HClose(UnFichier) // Fermeture de la connexion
Native Connectors (Native Accesses)

Native Oracle Connector: managing the external authentication

To connect via an external authentication, the following connection parameters must be used:
  • <Username> = / (slash)
  • <Password> = "" (empty string)
Remark: The external authentication consists in using the name of Windows user and his password to connect to the database. The external authentication requires configuring the server. See the Oracle documentation to learn more about how to authorize external authentications on the server.


  • AndroidAndroid Widget Only the hNativeAccessSQLite constant is available for Android.
Component: wd280hf.dll
Minimum version required
  • Version 9
This page is also available for…
Exemplo com porta diferente
Banco is string = INIRead("Database","Banco","",fCurrentDir()+"\ConfigDB.ini")
DNS_IP is string = INIRead("Database","DNS-IP","",fCurrentDir()+"\ConfigDB.ini")
Porta is string = INIRead("Database","Porta","",fCurrentDir()+"\ConfigDB.ini")
Usuario is string = INIRead("Database","Usuario","",fCurrentDir()+"\ConfigDB.ini")
Senha is string = INIRead("Database","Senha","",fCurrentDir()+"\ConfigDB.ini")

IF Usuario = "" AND Senha = "" THEN

MyHfsql01 is Connection
MyHfsql01..Provider = hAccessHFClientServer
MyHfsql01..Database = Banco
MyHfsql01..Server = DNS_IP
MyHfsql01..Source = DNS_IP +":"+ Porta
MyHfsql01..User = Usuario
MyHfsql01..Password = Senha

IF HOpenConnection(MyHfsql01) = True THEN

IF HChangeConnection("*",MyHfsql01) = True THEN
ToastDisplay("Conexao com sucesso!",toastLong,vaMiddle,haCenter)

25 Oct. 2022
Conexao PostgreSQL com porta diferente da Padrão
PROCEDURE ConexaoPostgreSQL()

ok1, ok2 is boolean


MyConnect is Connection
MyConnect..Provider = hNativeAccessPostgreSQL
MyConnect..Server = EDT_Host
MyConnect..Source = EDT_Host//+";"+val(EDT_Porta)
MyConnect..Database = EDT_DB
MyConnect..User = EDT_User
MyConnect..Password = EDT_Pass
MyConnect..ExtendedInfo = "WD Cache Size = 10000; Server Port="+Val(EDT_Porta)+";"

IF HOpenConnection(MyConnect) = True THEN
ok1 = True
IF HChangeConnection("*",MyConnect) = True THEN
ok2 = True

IF ok1 = True AND ok2 = True THEN
ToastDisplay("Conectou com Sucesso no PostgreSQL!",toastLong,vaMiddle,haCenter,RGB(0,0,255))
10 Jul. 2020
HCS.Timeout & HCS.FrameSize
A variável HCS.Timeout é usada para modificar o tempo limite da conexão:
Para as conexões estabelecidas pelo HOpenConnection .
Para as aberturas de conexão automática.
Nota : A variável HCS.Timeout é ignorada para os acessos ao servidor que não seja a conexão. Um pedido cuja execução é maior do que o valor especificado na variável HCS.Timeout não seria interrompida, por exemplo. Esse tempo limite deve ser especificado no aplicativo cliente, antes que uma conexão seja aberta no servidor.


A variável HCS.FrameSize é usada para redimensionar o quadro de dados de saída. Em alguns casos, o redimensionamento dos quadros pode ser usado para adaptar o fluxo de dados de saída e de entrada aos desempenhos do hardware usado. Por exemplo, se a conexão entre os computadores clientes e o mecanismo HFSQL Client / Server for através de redes de configuração (placa de rede, switch, roteador, vpn, ...)

HCS.FrameSize = hInternetFrame
28 Aug. 2017
Exemplo de uso do driver nativo MS SQL SERVER
ok, ok1, ok2, ok3 is boolean

myConn is Connection
myConn..Provider = hNativeAccessSQLServer
myConn..User = "adriano"
myConn..Password = "adriano@2016"
myConn..Source = "\projeto01"
myConn..Database = "projeto01"
myConn..Access = hOReadWrite

ok1 = HOpenConnection(myConn)
IF ok1 = False THEN
Info(ErrorOccurred() +" - "+ HErrorInfo())

IF gpwInitAnalysis() = False THEN
ok2 = False

ok2 = True
IF gpwOpen() = gpwOk
ok3 = True
Info(ErrorOccurred() +" - "+ HErrorInfo())
ok3 = False



IF ok1 = True AND ok2 = True AND ok3 = True THEN //deve dar tudo ok

Info("Conectou com sucesso no banco de dados!")


Info("Falha ao tentar conectar no Servidor")

28 Nov. 2016

Last update: 07/01/2023

Send a report | Local help