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.
  • 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 the HOpenConnection and HDWriteConnection functions
  • UDL file (file for describing an OLE DB connection)
  • Native Oracle Connector: managing the external authentication
  • Limitations
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
Opens a connection to a specific database. The connection remains opened until the call to HCloseConnection. The HOpenConnection function allows you 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.
    PHP This option is not available.
    Java 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 .
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function can only be used to handle HFSQL Client/Server connections.
New in version 18
Android Widget This function is now available in Android widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function can only be used to handle HFSQL Client/Server connections.
Android Widget This function is now available in Android widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function can only be used to handle HFSQL Client/Server connections.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Reports and QueriesWindowsLinuxUniversal Windows 10 AppJavaUser code (UMC)AjaxHFSQLHFSQL Client/ServerOLE DBNative 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
 
HOpenConnection(MaConnexion)
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).
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 occurred. 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 Property Name used on an 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 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 Managing ports.
Versions 15 and later
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.
New in version 15
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.
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.
Java Access by JDBC:
  • This parameter must correspond to URL of the connection to the database. This URL is specific to each driver.
  • Depending on the JDBC driver used, the database name must be specified in the connection URL.
AndroidAndroid Widget
Versions 18 and later
For a connection to an HFSQL Client/Server database on the development computer from an Android emulator, you must use the IP address 10.0.2.2 with the server port. Example: "10.0.2.2:4900".
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: "Server@domain.com:4900".
New in version 18
For a connection to an HFSQL Client/Server database on the development computer from an Android emulator, you must use the IP address 10.0.2.2 with the server port. Example: "10.0.2.2:4900".
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: "Server@domain.com:4900".
For a connection to an HFSQL Client/Server database on the development computer from an Android emulator, you must use the IP address 10.0.2.2 with the server port. Example: "10.0.2.2:4900".
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: "Server@domain.com:4900".
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.
<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 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).
    Versions 20 and later
    hNativeAccessMariaDB
    New in version 20
    hNativeAccessMariaDB
    hNativeAccessMariaDB
    Native 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).
    Versions 16 and later
    hNativeAccessSQLAzure
    New in version 16
    hNativeAccessSQLAzure
    hNativeAccessSQLAzure
    Native SQL Azure Connector (optional module of WINDEV/WEBDEV, supplied with Native SQL Server Connector).
    Versions 16 and later
    hNativeAccessSQLite
    New in version 16
    hNativeAccessSQLite
    hNativeAccessSQLite
    Native 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 (supplied 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.
    Versions 19 and later
    hOledbAccess2010
    New in version 19
    hOledbAccess2010
    hOledbAccess2010
    OLE DB provider for Access 2010.
    hOledbDBase5OLE DB provider for dBase 5.
    hOledbExcel2007OLE DB provider for Excel 2007.
    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

    AndroidAndroid Widget The available constants are as follows:
    Versions 15 and later
    hNativeAccessSQLite
    New in version 15
    hNativeAccessSQLite
    hNativeAccessSQLite
    Native SQLite Connector for Android applications.

    Java The available constants are as follows:
    hAccessHF7Pseudo-connection to an HFSQL database
    hAccessHFClientServerConnection to an HFSQL Client/Server database.
    hAccessJDBCMySQLAccess to MySQL database via JDBC.
    Versions 15 and later
    hAccessJDBCSQLite
    New in version 15
    hAccessJDBCSQLite
    hAccessJDBCSQLite
    Access to SQLite database via JDBC.
    hAccessJDBCSQLServerAccess to SQL Server database via JDBC.
OLE DB Caution: To use an OLE DB connection, you must:
  • install MDAC version 2.6 or later (setup performed by WINDEV/WEBDEV and when creating the client version).
  • install the OLE DB provider corresponding to the database used.
    This parameter is returned by the CtOLEDBProvider property.
PHP This parameter can correspond to one of the following constants:
hNativeAccessAS400Native AS/400 Connector (optional module of WEBDEV).
Versions 20 and later
hNativeAccessMariaDB
New in version 20
hNativeAccessMariaDB
hNativeAccessMariaDB
Native MariaDB Connector (optional module of WINDEV/WEBDEV).
hNativeAccessMySQLNative MySQL Connector (optional module of WEBDEV).
Versions 15 and later
hNativeAccessOracle
New in version 15
hNativeAccessOracle
hNativeAccessOracle
Native Oracle Connector (optional module of WEBDEV).
Versions 15 and later
hNativeAccessPostgreSQL
New in version 15
hNativeAccessPostgreSQL
hNativeAccessPostgreSQL
Native PostgreSQL Connector (optional module of WEBDEV).
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.
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.
HFSQL Client/Server This constant is ignored.
This parameter can be retrieved and modified using the Access property on a variable of type Connection.
Java Access by JDBC: This parameter is ignored.
PHP This parameter is not available.
<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 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.
OLE DBNative 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 Keywords recognized for the access by 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.
ENCRYPTIONEnables the encryption of data exchanged between Client and Server.
This keyword can take two values:
  • FAST
  • RC5_16 for a RC5 encryption (16 rounds).
DB_EXISTChecks the existence of the database. If the specified database does not exist, this database is not created and HOpenConnection returns False.
This parameter can be retrieved and modified using the ExtendedInfo property.
Java HFSQL database accessed via a RMI server: This parameter corresponds to the address of RMI server and to the port used. The following format must be used: "RMI=<Server address>:<Port number>". For example: "RMI=192.168.52.148:1099".
Java Access by JDBC: This parameter is mandatory. It must correspond to the full name of JDBC driver to use. This name is case sensitive.
PHP This parameter is not available.
<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 (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 can be retrieved and modified using the CursorOptions property.
PHP This parameter is not available.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax

Defining and opening a connection by defining the connection string Hide the details

<Result> = HOpenConnection(<Connection> , <ADO connection string> [, <Access>])
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurred. HErrorInfo is used to identify the error. The connection description will be deleted when closing the connection.
<Connection>: 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 by HOpenConnection or HDescribeConnection).
<ADO connection string>: Character string
ADO connection string to use. For more details on the syntax of this connection string, see the documentation of the OLE DB provider used.
<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.
Remarks
WINDEVWEBDEV - Server codeReports and QueriesUniversal Windows 10 AppiPhone/iPadUser code (UMC)PHPAjaxHFSQLHFSQL Client/ServerOLE DBNative 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 is using 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.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjaxHFSQLHFSQL Client/ServerOLE DBNative Connectors (Native Accesses)

Syntax 2: 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:
  1. In the data model editor, open the connection description window ("Analysis .. Connection")
  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.
Using a character string for the OLE DB provider
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjaxHFSQLHFSQL Client/ServerOLE DBNative 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.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadUser code (UMC)AjaxHFSQL

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 the HOpenConnection and HDWriteConnection functions

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 data file, in a specific process, the connection to the Oracle database will be made only when needed.
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(MaConnexion, params)
HChangeConnection(UnFichier, MaConnexion)
...
HReadFirst(unFichier) // Ouverture de la connexion
...
HClose(UnFichier) // Fermeture de la connexion
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)AjaxOLE DB

UDL file (file for describing an OLE DB connection)

To create a UDL file:
  1. Create a text file whose extension is "UDL".
  2. Double-click this file. The window for the properties of the data links is opened.
  3. Configure the connection.
  4. Run the test of the connection.
  5. Validate ("OK" button). The UDL file can now be used.
Versions 18 and later
WINDEVWEBDEV - Server codeNative 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 a setting of the server. See the documentation about Oracle to find out how to authorize the external authentications on the server.
New in version 18
WINDEVWEBDEV - Server codeNative 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 a setting of the server. See the documentation about Oracle to find out how to authorize the external authentications on the server.
WINDEVWEBDEV - Server codeNative 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 a setting of the server. See the documentation about Oracle to find out how to authorize the external authentications on the server.

Limitations

  • WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjaxHFSQLHFSQL Client/ServerOLE DBNative Connectors (Native Accesses) This function is not available when using a database via Remote Access.
  • AndroidAndroid Widget Only the hNativeAccessSQLite constant is available for Android.
Component: wd270hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment