ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / SQL functions
  • Lookup table between the different types of databases, their sources and their databases
  • Failure or success of connection
  • Connection to an HFSQL analysis
  • Native MySQL, MariaDB and PostgreSQL Connectors
  • Native MySQL, MariaDB and PHP Connectors
  • Connection to an ISAM database via ACCESS
  • Native Oracle Connector: managing the external authentication
  • SQL query (HExecuteSQLQuery or queries created in the query editor)
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
Connects the current application to a database that must be interrogated via SQL.
Native Connectors (Native Accesses)
// Connexion à une base de données MySQL:
// machine apollon, login "superv", base de données client test
NumConnexion is int
NumConnexion = SQLConnect("apollon", "superv", "", "test")
Syntax
<Result> = SQLConnect(<Source> , <User> , <Password> [, <DataBase name> [, <Database type> [, <OLE DB provider> [, <Optional information>]]]])
<Result>: entier
<Source>: Character string
Name of data source (alse called Data Source Name). If the data source contains several "Databases", you must specify the name of the "Database" used (<Database name> parameter). For more details, see the remarks.
Native Connectors (Native Accesses) MySQL and MariaDB: This parameter corresponds to the name or IP address of the computer containing the database. For example, "Apollon".
<User>: Character string
User name. This name is optional for some data sources: in this case, use an empty string ("") for this parameter.
<Password>: Character string
Password corresponding to the specified user. This password is optional for some data sources: in this case, use an empty string ("") for this parameter.
<DataBase name>: Optional character string
Name of the database to use. For more details, see the Remarks.
  • If this parameter is specified, a dialog box specific to the driver is displayed during the connection. This dialog box may not be displayed according to the driver used.
  • If this parameter is not specified, no dialog box is displayed.
Native Connectors (Native Accesses) MySQL and MariaDB: With Native MariaDB Connector, the database name is mandatory.
<Database type>: Optional character string
Type of accessed database. The types of databases installed on the current computer are returned by SQLListSource. For more details, see the remarks.
<OLE DB provider>: Optional character string or constant
Name of OLE DB provider used. The most common ones are as follows:
"SQLOLEDB"SQLServer
"MSDASQL"ODBC
"Microsoft.Jet.OLEDB.3.51"Access
"Microsoft.Jet.OLEDB.4.0"Access
"MSDAORA"Oracle (Microsoft)
"OraOLEDB.Oracle"Oracle
or one of the following constants:
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.
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.

Caution: To use an OLE DB connection, you must:
  • install MDAC version 2.6 or later (setup performed by WINDEV or WEBDEV when installing the application)
  • install the OLE DB provider corresponding to the database used.
<Optional information>: Optional character string (not to be used with HFSQL or direct ODBC)
Used to specify the optional information. You can for example specify "Trusted_Connection=YES" in order to use a connection with authentication via the NT login. If several optional information must be specified, they must be grouped in a single character string and they must be separated by the ";" character.
Native Connectors (Native Accesses) The keywords recognized by OLE DB and the Native Connectors are displayed on Optional connection information.
Remarks

Lookup table between the different types of databases, their sources and their databases

Database typeSourceDataBase name
ACCESSName of Access file"" (empty string)
AS400Native AS/400 Connector (optional module)
DB2Native DB2 Connector (optional module)
Source defined in ODBC Administrator.
"" (empty string) or Database
HYPER FILE
HFSQL
Database name"" (empty string)
HFSQLCSName or address of serverDatabase name
INFORMIXNative Informix Connector (optional module)
JDBCURL for connecting to the database. This URL is specific to each driver.The database must be specified in the connection URL. This URL is specific to each JDBC driver.
HIVEURL for connecting to the Hive server.Database
MariaDBNative MariaDB Connector (optional module)
Database name
Database
MySQLNative MySQL Connector (optional module)
Database name
Database
POSTGRESQLNative PostgreSQL Connector (optional module)
Database name
Database
ODBCSource defined in ODBC Administrator"" (empty string) or Database
OLEDBSource name"" (empty string)
ORACLENative Oracle Connector (optional module)
Name of the alias defined in SQL NET Easy configuration and in WDORAINS.
"" (empty string)
PROGRESSNative Progress Connector (optional module)
Source defined in ODBC Administrator.
"" (empty string) or Database
SQL AZURENative SQL Azure Connector (optional module supplied with the Native SQL Server Connector)
Server name.
If the name of the server is such as: ServerName.database.windows.net, the login must have the following format: login@ServerName.
Database
SQL SERVERNative SQL SERVER Connector (optional module)
Server name.
"" (empty string)
SYBASENative SYBASE Connector (optional module)
Name of server or its alias.
"" (empty string)
xBaseNative xBase Connector (supplied with the product)
Database available via a browser
(available in Chrome and Safari only)
"" (empty string)
"" (empty string)

Failure or success of connection

If the connection is successful, the connection identifier can be used to change the connection (SQLChangeConnection).
If the connection fails, the SQL.Error and SQL.MesError variables are not initialized. For more details about the connection failure, use SQLInfo.
In any case (failure or success), the connection must be closed (SQLDisconnect).
HFSQL ClassicHFSQL Client/Server

Connection to an HFSQL analysis

To connect to an HFSQL analysis, use the following syntax:
SQLConnecte("<Lecteur>:<Chemin complet WDD analyse>", "", "<Mot De Passe Analyse>")
For example:
SQLConnect("D:\WINDEV\WDSTOCK\WDSTOCK.WDD", "", "")
Remarks:
  • After the connection to an HFSQL analysis, SQL.Connection returns -1.
  • For the HFSQL analysis, a single connection can be established at one time in the same project.
    If the analysis was already opened by HOpenAnalysis or if the project is associated with the analysis, SQLConnect does not re-open the analysis.
    On the contrary, if the analysis is not opened yet, it is automatically opened by SQLConnect.
  • If the HFSQL data files are not found in the current program directory or in the directory described in the analysis, the directory must be modified by HChangeDir.
  • If a password has been set for the analysis, it must be specified in the third parameter passed to SQLConnect.
Native Connectors (Native Accesses)

Native MySQL, MariaDB and PostgreSQL Connectors

To open a connection to a MySQL, MariaDB or PostgreSQL database thorough a Native Connector (also called Native Access), you need to pass the following elements as parameters to SQLConnect:
  • the type of the database used, MySQL, MariaDB or POSTGRESQL.
  • the database name: it corresponds to the name given by the administrator of the MySQL/MariaDB/PostgreSQL database.
Remark: The name of the MySQL or PostgreSQL data source can be replaced with the name or the IP address of the computer where the database is available. In any case, the name of the "Database" must be specified.
// Connexion à une base de données MySQL locale
NumConnexion = SQLConnect("BaseMySQL", "", "", "", "MySQL")
// ou NumConnexion = SQLConnecte("BaseMySQL", "Utilisateur", "MotDePasse", "MaDataBase", "MySQL")
 
// Connexion à une base de données MySQL distante
NumConnexion = SQLConnect("192.168.1.51", "Utilisateur", "MotDePasse", "test", "MySQL")
Native Connectors (Native Accesses)

Native MySQL, MariaDB and PHP Connectors

To open a connection in PHP:
  • to a MySQL database, it is recommended to pass the hNativeAccessMySQL constant as parameter to SQLConnect.
  • to a MariaDB database, it is recommended to pass the hNativeAccessMariaDB constant as parameter to SQLConnect.
The Native Connector (MySQL or MariaDB) is required to develop the WEBDEV site but it is not required for the site to operate: there is no need to install the Native Connector at the hosting company. Indeed, at run time, it is the MySQL/MariaDB client of the current PHP engine that is used.
Native Connectors (Native Accesses)

Connection to an ISAM database via ACCESS

The following syntax is used to connect to an ISAM database:
SQLConnecte(<Chemin de la base de données>, <Utilisateur>, <Mot de passe>,
<Type de la base de données>, "ACCESS")
<Database path>Path or full name (depending on the case) of the database accessed.
<User>User name. It is optional for some databases.
<Password>Password for this user. It is optional for some databases.
<Database type>Type of the database where the connection must be established (the corresponding ISAM driver must have been installed).
Type of database<Database type><Database path>
dBASE III"dBASE III"drive:\directory
dBASE IV"dBASE IV"drive:\directory
dBASE 5"dBASE 5.0"drive:\directory
Paradox 3.x"Paradox 3.x"drive:\directory
Paradox 4.x"Paradox 4.x"drive:\directory
Paradox 5.x"Paradox 5.x"drive:\directory
FoxPro 2.0"FoxPro 2.0"drive:\directory
FoxPro 2.5"FoxPro 2.5"drive:\directory
FoxPro 2.6"FoxPro 2.6"drive:\directory
Excel 3.0"Excel 3.0"Drive:\directory\file.xls
Excel 4.0"Excel 4.0"Drive:\directory\file.xls
Excel 5.0 or Excel 95"Excel 5.0"Drive:\directory\file.xls
Excel 97"Excel 8.0"Drive:\directory\file.xls
HTML Import"HTML Import"Drive:\directory\filename
HTML Export"HTML Export"drive:\directory
Text"Text"drive:\directory

Remarks:
  • In order for the requested connection to be established, the corresponding ISAM driver must have have been installed. The setup program of MS OFFICE 97 proposes several ISAM drivers.
  • The ACCESS and ISAM databases are accessible in 32-bit mode only.
  • The WDMemoBinary WLanguage keyword, used to add or change a binary memo via an SQL query, is not supported by the HFSQL engine and the ACCESS driver. For an HFSQL database, use memo-specific functions.
    You can also use:
    • the 'UNHEX' SQL function with hexadecimal content
    • the WL.Decode function with the encodeBASE64NoCR constant and a string encoded in Base64.
Native Connectors (Native Accesses)

Native Oracle Connector: managing the external authentication

To connect via an external authentication, the following connection parameters must be used:
  • <User> = / (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.
HFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

SQL query (HExecuteSQLQuery or queries created in the query editor)

When using the SQL DELETE, INSERT or UPDATE statements, no integrity check and no duplicate check are performed on an HFSQL database. This feature is not available in this version.
Solution: Use the HFSQL functions (HDelete, HAdd or HModify) on your data files. The integrity check and the duplicate check will be automatically performed.
Component: wd290hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo de conexao em outra porta do Postgresql
nDBConnection = SQLConnect("127.0.0.1",sUser,sPassword,sDBName,"PostgreSQL","","Server Port = 15433")

by Ronei Heck
Boller
12 Apr. 2023

Last update: 07/06/2023

Send a report | Local help