Je voudrais utiliser la fonction SAVEPOINT COMMIT ROLLBACK mais je ne trouve pas d'info dessus pour l'utiliser dans des macros sans formulaire reliés à la base
j'ai une base de données MySQL relié à une base de données BASE. Je fais des macros dans Calc en utilisant les Dialogues.
Code : Tout sélectionner
Connexion à la base (MySQL)
' Feuille de connexion
oFeuilleToto = ThisComponent.Sheets.getByName("Toto")
' Connexion Base
oDatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
oDataSource = oDatabaseContext.getByName("BaseTest")
' Identifant et Mot de passe
If Not oDataSource.IsPasswordRequired Then
'Les paramètres de connexion
login = ""
password = ""
maConnexion = maSource.getIsolatedConnection(login, password)
oConnection = oDataSource.GetConnection("","")
Else
oInteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
oConnection = oDataSource.ConnectWithCompletion(oInteractionHandler)
End If
' objet de connexion à utiliser dans le projet
oStatement1 = oConnection.createStatement()
' objet de connexion à utiliser dans le projet
oStatement2 = oConnection.createStatement()
Code : Tout sélectionner
strSQLInsertMod = "INSERT INTO tblmodule" & _
"( mod_fpdID, mod_stgID, mod_JoursSemaine, mod_Date, mod_LastModif, mod_DateCreat ) " & _
" VALUES ( '" & addIDFpd & "' , '" & smodstgID & "' , '" & smodJoursSemaine & "' , '" & Format(dDateDebut,"YYYY/MM/DD") & "' , '" & _
strDateHH & "' , '" & strDate & "' ) "
'msgbox (strSQLInsertMod)
lResultSetInsertMod = oStatement1.executeUpdate(strSQLInsertMod)
' Recuperation de l'ID nouvellement créé
strSQLLastInsertMod = "SELECT LAST_INSERT_ID()"
oResultSetLastInsertMod = oStatement1.executeQuery( strSQLLastInsertMod )
et des UPDATE
Code : Tout sélectionner
strSQLUpdateModSecond = "UPDATE tblmodule " & _
" SET mod_SecondID = '" & smodSecondID & "'" & _
" WHERE ( mod_ID = '" & addIDMod & "')"
'msgbox( strSQLUpdateModSecond)
lResultSetUpdateModSecond = oStatement1.executeUpdate(strSQLUpdateModSecond)
Merci d'avance