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
  • Example 1: Transaction of a database opened by SQLConnect
  • Example 2: Changing the database name (OLE DB)
SQLTransaction (Example)
Example 1: Transaction of a database opened by SQLConnect
Reports and QueriesOLE DB The following example is used to perform operations in a transaction during an access to a database performed by SQLConnect. The transaction is then rolled back: the operations are not recorded in the data file.
NumConnexion is int = SQLConnect("MaBase", "User", "MotDePasse", "", "OLEDB", "MonProvider")
IF NumConnexion = 0 THEN
   	SQLInfo()
   	Error("Erreur d'ouverture de la connexion :" + SQL.MesError)
ELSE
   	// Mise en transaction de la connexion
   	SQLTransaction(sqlStart)
   	// Modification de la valeur de toutes les rubriques UnFichier.UneRubrique
   	IF SQLExec("UPDATE UnFichier SET UneRubrique = 'nouvelle valeur'", "RequeteModif") = 0 THEN
      		SQLInfo("RequeteModif")
      		Error("Erreur d'exécution de la requête :" + SQL.MesError)
      		SQLTransaction(sqlCommit)
  	END
  	// Annulation de la transaction
  	SQLTransaction(sqlRollBack)
  	// Le contenu du fichier UnFichier n'a pas changé
END
Example 2: Changing the database name (OLE DB)
Reports and QueriesOLE DB The following example is used to perform operations in a transaction during an access to a data file that uses a connection described in the analysis.
The transaction is then rolled back: the operations are not recorded in the data file.
In this example, AFile is an OLE DB data file described in the data model editor. This data file uses the connection named MyConnection described in the data model editor.
HReadFirst(UnFichier)
// Mise en transaction de la connexion
SQLTransaction(sqlStart, MaConnexion)
// Modification de la valeur de la rubrique
UnFichier.UneRubrique = "nouvelle valeur"
HModify(UnFichier)
// Annulation de la transaction
SQLTransaction(sqlRollBack, MaConnexion)
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