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: Importing a file description from an existing data file
  • Example: Importing an HFSQL Client/Server file with password
  • Example: Connecting to the file of Groupware users
  • Example: Executing a SQL query on a data source declared by the HDeclareExternal function
HDeclareExternal (Example)
Example: Importing a file description from an existing data file
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)Ajax
The following example allows you to use the "C:\AnExample\CUSTOMER.FIC" file in the current application. This data file is described in the "Example" application. It is imported into the current application as "CustomerWD". Its structure is automatically imported into the analysis of the current project. This allows you to add a record into this data file for example.
ClientWD is Data Source
// Importe la description du fichier CLIENT sous le nom ClientWD
HDeclareExternal("C:\UnExemple\CLIENT.FIC", "ClientWD")

// Ajout d'un enregistrement
ClientWD.Nom = "Martin"
...
HAdd(ClientWD)

// Ferme le fichier
HClose(ClientWD)

// On ne veut plus utiliser la description
HCancelDeclaration(ClientWD)
Example: Importing an HFSQL Client/Server file with password
sdMonHotel is Data Source
Nouvelle_connexion is Connection

HPass(sdMonHotel, "Tahiti")

// Paramètres de la connexion
Nouvelle_connexion.Provider = hAccessHFClientServer
Nouvelle_connexion.User = "MonUtilisateur"
Nouvelle_connexion.MotDePasse = "MonMotDePasse"
Nouvelle_connexion.Server = "MonIPServeur"
Nouvelle_connexion.Database = "MaBaseDeDonnees"

// Ouverture de la connexion
IF NOT HOpenConnection(Nouvelle_connexion) THEN
	Error("Erreur de connexion : ", HErrorInfo())
	RETURN
END
IF NOT HDeclareExternal(".\Hotels.fic","sdMonHotel", Nouvelle_connexion) THEN
	Error("Erreur sur la déclaration externe : ", HErrorInfo())
	RETURN
END

HReadFirst(sdMonHotel)
Info(sdMonHotel.Nom)
Example: Connecting to the file of Groupware users
This example explains how to connect to the user file of User Groupware when this file is an HFSQL Client/Server file.
sdGPWUTIL is Data Source
Nouvelle_connexion is Connection

// Paramètres de la connexion
Nouvelle_connexion.Provider = hAccessHFClientServer
Nouvelle_connexion.User = "mon utilisateur"
Nouvelle_connexion.MotDePasse = "mon mot de passe"
Nouvelle_connexion.Server = "mon serveur"
Nouvelle_connexion.Database = "ma base de données"
Nouvelle_connexion.Encryption = hEncryptionNO

// Ouverture de la connexion
IF NOT HOpenConnection(Nouvelle_connexion) THEN 
	Error(HErrorInfo())
	RETURN
END

HPass(sdGPWUTIL,"PCSGPW2001")
IF NOT HDeclareExternal(".\Gpw_GPWU_HFCS\\GPWUTILISATEUR.fic", sdGPWUTIL, Nouvelle_connexion) THEN
	Error(HErrorInfo())
	RETURN
END

sdGPWUTIL.login = "testman"
IF NOT HAdd("sdGPWUtil") THEN Error(HErrorInfo())
Example: Executing a SQL query on a data source declared by the HDeclareExternal function
This example shows how to execute a SQL query on a data source declared by the HDeclareExternal function. The "Name" property must be used.
// Connexion à la base de données
cnxConnexionSuivi is Connection
cnxConnexionSuivi.User = "Nom_Utilisateur"
cnxConnexionSuivi.MotDePasse = ""
cnxConnexionSuivi.Server = "Nom_Server"
cnxConnexionSuivi.Database = "Nom_Base"
cnxConnexionSuivi.Provider = hAccessHFClientServer
cnxConnexionSuivi.Access = hOReadWrite   

sArticle is Data Source  
sdRetourReq is Data Source

sReq  is string =
[
	SELECT *
	FROM %1
]

IF NOT HOpenConnection(cnxConnexionSuivi) THEN
	Trace("Erreur de connexion à la BDD du suivi" + CR + HErrorInfo(hErrFullDetails))
	EndProgram()
END
IF NOT HDeclareExternal(".\ARTICLE.FIC", sArticle, cnxConnexionSuivi) THEN
	Trace("Le fichier sArticle n'a pas pu être déclaré" + CR + HErrorInfo(hErrFullDetails))
	EndProgram()
END
sReq = StringBuild(sReq, sArticle..Name)
Trace(sReq)
IF HExecuteSQLQuery(sdRetourReq, cnxConnexionSuivi, hQueryDefault, sReq) THEN
	FOR EACH sdRetourReq
		Trace(sdRetourReq.DESA_ART)
	END
ELSE
	Trace(HErrorInfo(hErrFullDetails))
	EndProgram()   
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