6 messages in org.openoffice.fr.progRe: Un essai infructueux de Macro
FromSent OnAttachments
Jean SympaAug 8, 2007 7:05 am 
aladdinAug 9, 2007 5:41 am 
Jean SympaAug 10, 2007 3:08 am 
Francois GattoAug 10, 2007 10:19 am 
jean...@centraliens.netAug 11, 2007 6:06 am 
aladdinAug 12, 2007 3:40 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Un essai infructueux de MacroActions...
From:aladdin (alad@altern.org)
Date:Aug 9, 2007 5:41:16 am
List:org.openoffice.fr.prog

Bonjour,

Un essai infructueux de Macro

Par exemple si vous une base de donnée qui s'appelle test avec une table DVD et comme champs :

id (int) Genre (varchar) TitreFilm (varchar) PrixAchat (int)

Vous pouvez parcourir votre table en utilisant cet exemple : Sub maConnexionBase Dim monServiceDB As Object, maSource as Object, maConnection as Object, monStatement As Object, monResultSet as Object

Dim dbName as String

Dim maRequeteSQL As String, monTexte As String, Login As String, MotDePasse As String Dim i As Integer

'Nom de la base de donnée 'Affichage > Source de données ou en appuyant sur F4

dbName = "test"

'Paramètres de connexion Login = "" MotDePasse = ""

'Vote requête SQL maRequeteSQL = "select * from DVD"

'Connexion à la base monServiceDB = createUnoService("com.sun.star.sdb.DatabaseContext") maSource = monServiceDB.getByName(dbName) maConnection = maSource.GetConnection(Login,MotDePasse)

'SQL monStatement = maConnection.createStatement() monResultSet = monStatement.executeQuery(maRequeteSQL)

'Affichage des résultats 'getString ou getInt en fonction du type de la variable 'avec en paramètre le numéro de la colonne 'ici la 3 ème colonne => TitreFilm 'et la 4 ème => PrixAchat While monResultSet.next MsgBox "Le DVD " + monResultSet.getString(3) + " est à " + monResultSet.getInt(4) + " €" i = i + 1 Wend

'Fermeture de la connexion monResultSet.close() maConnection.close() End Sub

Cordialement,