AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / HFSQL / Funciones HFSQL
  • 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
Reportes y ConsultasWindows
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.
CustomerWD is Data Source
// Imports the description of CUSTOMER file as CustomerWD
HDeclareExternal("C:\AnExample\CUSTOMER.FIC", "CustomerWD")

// Add a record
CustomerWD.Name = "Montgomery"
...
HAdd(CustomerWD)

// Closes the file
HClose(CustomerWD)

// The description is not required anymore
HCancelDeclaration(CustomerWD)
Example: Importing an HFSQL Client/Server file with password
dsMyHotel is Data Source
New_connection is Connection

HPass(dsMyHotel, "Tahiti")

// Connection parameters
New_connection.Provider = hAccessHFClientServer
New_connection.User = "MyUser"
New_connection.Password = "MyPassword"
New_connection.Server = "MyServerIP"
New_connection.Database = "MyDatabase"

// Open the connection
IF NOT HOpenConnection(New_connection) THEN
	Error("Connection error: ", HErrorInfo())
	RETURN
END
IF NOT HDeclareExternal(".\Hotels.fic","dsMyHotel", New_connection) THEN
	Error("External declaration error: ", HErrorInfo())
	RETURN
END

HReadFirst(dsMyHotel)
Info(dsMyHotel.Name)
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.
dsUSERGPW is Data Source
New_connection is Connection

// Connection parameters
New_connection.Provider = hAccessHFClientServer
New_connection.User = "my user"
New_connection.Password = "my password"
New_connection.Server = "my server"
New_connection.Database = "my database"
New_connection.Encryption = hEncryptionNO

// Open the connection
IF NOT HOpenConnection(New_connection) THEN 
	Error(HErrorInfo())
	RETURN
END

HPass(dsUSERGPW, "PCSGPW2001")
IF NOT HDeclareExternal(".\Gpw_GPWU_HFCS\\USERGPW.fic", dsUSERGPW, New_connexion) THEN
	Error(HErrorInfo())
	RETURN
END

dsUSERGPW.login = "testman"
IF NOT HAdd("dsUSERGPW") 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.
// Connect to the database
cnxConnexionSuivi is Connection
cnxConnexionSuivi.User = "Nom_Utilisateur" (User_Name)
cnxConnexionSuivi.Password = ""
cnxConnexionSuivi.Server = "Server_Name"
cnxConnexionSuivi.Database = "Nom_Base"
cnxConnexionSuivi.Provider = hAccessHFClientServer
cnxConnexionSuivi.Access = hOReadWrite   

sArticle is Data Source  
sdRetourReq is Data Source

sReq is TO string =
[
	SELECT *
	FROM %1
]

IF NOT HOpenConnection(cnxConnexionSuivi) THEN
	Trace("Follow-up DB connection error" + CR + HErrorInfo(hErrFullDetails))
	EndProgram()
END
IF NOT HDeclareExternal(".\ARTICLE.FIC", sArticle, cnxConnexionSuivi) THEN
	Trace("The file sArticle could not be declared" + CR + HErrorInfo(hErrFullDetails))
	EndProgram()
END
sReq = StringBuild(sReq, sArticle..Name)
Trace(sReq)
IF HExecuteSQLQuery(sdRetourReq, cnxConnexionSuivi, hQueryDefault, sReq) THEN
	FOR ALL sdRetourReq
		Trace(sdRetourReq.DESA_ART)
	END
ELSE
	Trace(HErrorInfo(hErrFullDetails))
	EndProgram()   
END
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local