ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Example 1: Describing a connection on SQL Server via OLE DB
  • Example 2: Describing a connection on SQL Server via OLE DB
  • Example 3: Description of a connection to HFSQL Classic data files
  • Example 4: Description of a connection to an Access file (MDB)
HDescribeConnection (Example)
Example 1: Describing a connection on SQL Server via OLE DB
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxUser code (UMC)AjaxOLE DB
In this example, the company database is on Oracle. The programmer wants to run the test of his program on an SQL Server database.
In the analysis, an OLEDB connection was associated with the "Salaries" OLE DB table on Oracle.
The properties of this connection are:
datasource: Oracle_Server
user: dupont
password: toto
provider: OraOLEDB.Oracle
The new connection to the SQL Server database will have the following parameters:
datasource: "Server_SQLServer"
database: "dbo"
user: ""
password: ""
provider: "SQLOLEDB"
Note: On SQLServer, you can define a database internal to the server data source.
// Décrire la nouvelle connexion
HDescribeConnection("MaConnexion", "", "", "Serveur_SQLServer", ...
		"dbo", hOledbSQLServer, hOReadWrite, "")

// Ouvrir la nouvelle connexion
HOpenConnection("MaConnexion")

// Indiquer que "Salaires" utilise la nouvelle connexion
HChangeConnection("Salaires", "MaConnexion")
// Commencer le parcours de la table "Salaires" sur SQL Server
HReadFirst("Salaires")
...
// Ferme le fichier : la connexion utilisée par le fichier "Salaires"
// a été ouverte par HOuvreConnexion. Elle ne sera pas fermée 
// lors de la fermeture du fichier "Salaires". 
HClose("Salaires")
...
// Ré-ouverture rapide car la connexion est toujours ouverte
HOpen("Salaires")

// Fermer la connexion
HCloseConnection("MaConnexion")

// Rétablir l'utilisation de la connexion sur Oracle
HChangeConnection("Salaires", "")

// Ouvrir la table "Salaires" sur Oracle
HOpen("Salaires")
Example 2: Describing a connection on SQL Server via OLE DB
WINDEVWEBDEV - Server codeWindowsUser code (UMC)AjaxOLE DB
The company database is on Oracle. The programmer wants to run the test of his program on an SQL Server database by using the ODBC access
Without modifying the analysis, you have the ability to change the connection used by the file.
Note: "ODBCSQLServer" is an ODBC data source declared in Windows ODBC data sources
// Décrire et ouvrir la nouvelle connexion
HDescribeConnection("MaConnexion", "", "", "Serveur_SQLServer", ...
		"dbo", hODBC, hOReadWrite, "")
HOpenConnection("MaConnexion")

// Indiquer que "Salaires" utilise la nouvelle connexion
HChangeConnection("Salaires", "MaConnexion")

// Commencer le parcours de la table "Salaires" sur SQLServer
HReadFirst("Salaires")
...

// Fermer la connexion
HCloseConnection("MaConnexion")

// Rétablir l'utilisation de la connexion sur Oracle
HChangeConnection("Salaires", "")
// Ouvrir la table "Salaires" sur Oracle
HOpen("Salaires")
Example 3: Description of a connection to HFSQL Classic data files
WINDEVUser code (UMC)
The company database is on Oracle. The developer wants to run the tests of his program on HFSQL Classic data files.
Without modifying the analysis, you have the ability to change the connection used by the file.
In the analysis, an OLEDB connection was associated with the "Salaries" OLE DB table on Oracle.
The properties of this connection are:
datasource: Oracle_Server
user: dupont
password: toto
provider: OraOLEDB.Oracle
The new pseudo-connection (using an HFSQL Classic database) will have the following parameters:
datasource: "c:ASLASH_Tmp"
database: ""
user: ""
password: ""
provider: hAccèsHF7
// Décrire la nouvelle connexion
HDescribeConnection ("MaConnexion", "", "", "c:\tmp", "", ...
	hAccessHF7, hOReadWrite, "")
// Indiquer que "Salaires" utilise la nouvelle connexion
HChangeConnection("Salaires", "MaConnexion")
// Commencer le parcours de la table "Salaires" sur SQLServer
HReadFirst("Salaires")
...
// Fermer le fichier
HClose("Salaires")
...
// Rétablir l'utilisation de la connexion sur Oracle
HChangeConnection("Salaires", "")
// Ouvrir la table "Salaires" sur Oracle
HOpen("Salaires")
Example 4: Description of a connection to an Access file (MDB)
WINDEVUser code (UMC)
The database of the company is on Access. The following code is used to access the data.
// Variables de connexion
sNomConnexion is string = "CNX_ACCESS"
sTypeConnexion is string = "Microsoft.Jet.OLEDB.4.0"
sTypeAccès is int = hOReadWrite
sNomSource is string = "C:\MaBaseAccess.mdb"
sNomBase is Data Source = ""
sNomUtilisateur is string = ""
sMotDePasse is string = ""

IF HDescribeConnection(sNomConnexion, sNomUtilisateur, sMotDePasse, ...
		sNomSource, sNomBase, sTypeConnexion, sTypeAccès) THEN
	IF HOpenConnection(sNomConnexion) THEN
		HChangeConnection(Cedex, "CNX_ACCESS")
		Info("Connexion créée." + CR + ...
			"Changement de connexion effectué")
	ELSE
		Error(HErrorInfo())
	END
ELSE
	Error(HErrorInfo())
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help