Bonjour
Je suis sous debian trixie, avec libreoffice 24.2.3.2
Je reprends un classeur que j’avais créé pour gérer les devis et factures, basé sur ooofact.
Dans celui-ci, je veux effectuer deux opérations sur la base de données enregistrée:
effacer la ligne ID=1
Rentrer les nouvelles infos à la place.
voici le code
Sub ConnecterSource()
'Création du contexte
NomSource = "BasePublipostage"
monDbContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
maSource = monDbContext.getByName(NomSource)
maConnexion = maSource.getConnection("","")
if IsNull(maConnexion) then
MsgBox("Connexion impossible", 16)
Stop
end if
End Sub
Sub DeconnecterSource()
maConnexion.close
maConnexion.dispose
End Sub
Sub ouvrirContrat(fich)
If Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools") then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If
dim Saisie as object, Factures as object, Clients as object, Presta as object, publie as object
dim Numero as String, NumDevis as string, NumAff as string, sDocUrl as string, Col as string, CompileDates as string, Ref as string
dim i as integer, Pd as integer, Nbrl as integer, cc as integer, Z as integer, y as integer, j as integer
Dim Fichier As String
Dim Wb As Object
Dim Args()
dim maRequete as Object, resultat as long
dim insertSQL as String, reqSQL as string
dim champBase(16) as string
<code pour remplir champBase, ça marche>
ConnecterSource
maRequete = maConnexion.createStatement()
'on efface les précédents enregistrements
reqSQL = "delete from " & Chr(34) & "BasePublipostage" & Chr(34) & " "
maRequete.executeUpdate(reqSQL)
'on insère les champs demandés
insertSQL = "insert into " & Chr(34) & "BasePublipostage" & Chr(34) & "(" & Chr(34) & "ID" & Chr(34) & "," & Chr(34) & "Nom structure" & Chr(34) & "," & Chr(34) & "Adresse" & Chr(34) & "," & Chr(34) & "Siret" & Chr(34) & "," & Chr(34) & "Licence" & Chr(34) & "," & Chr(34) & "APE" & Chr(34) & "," & Chr(34) & "Representant" & Chr(34) & "," & Chr(34) & "Prestation" & Chr(34) & "," & Chr(34) & "Montant presta" & Chr(34) & "," & Chr(34) & "Montant Kms" & Chr(34) & "," & Chr(34) & "Nbre prestas" & Chr(34) & "," & Chr(34) & "Dates" & Chr(34) & "," & Chr(34) & "compilDates" & Chr(34) & "," & Chr(34) & "Equipe" & Chr(34) & "," & Chr(34) & "Repas" & Chr(34) & "," & Chr(34) & "Hebergement" & Chr(34) & "," & Chr(34) & "Droits" & Chr(34) & ") values(" & Chr(39) & "1" & Chr(39) & "," & Chr(39) & champBase(1) & Chr(39) & "," & Chr(39) & champBase(2) & Chr(39) & "," & Chr(39) & champBase(3) & Chr(39) & "," & Chr(39) & champBase(4) & Chr(39) & "," & Chr(39) & champBase(5) & Chr(39) & "," & Chr(39) & champBase(6) & Chr(39) & "," & Chr(39) & champBase(7) & Chr(39) & "," & Chr(39) & champBase(8) & Chr(39) & "," & Chr(39) & champBase(9) & Chr(39) & "," & Chr(39) & champBase(10) & Chr(39) & "," & Chr(39) & champBase(11) & Chr(39) & "," & Chr(39) & champBase(12) & Chr(39) & "," & Chr(39) & champBase(13) & Chr(39) & "," & Chr(39) & champBase(14) & Chr(39) & "," & Chr(39) & champBase(15) & Chr(39) & "," & Chr(39) & champBase(16) & Chr(39) & ")"
maRequete.executeUpdate(insertSQL)
DeconnecterSource
End Sub
Et là, il ne se passe rien. Pas d’erreurs, aucune modification de la base de donnée.
C’est un code qui fonctionnait, mais plus, je m’arrache les cheveux dessus.
Comme j’ai le nez dedans depuis pas mal d’heures, il est possible que je passe à coté d’une énorme erreur sans la voir.
Est-ce que quelqu’un aurait un début de piste à me proposer?