Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Comment savoir si un UPDATE (mysql) a bien fonctionné ?

2 réponses
Avatar
Superman
Bonjour,

Voici mon code :

Dim pMySQL As Long
dim test as integer
dim Identifiant as string
dim newmdp as string

Identifiant =3D "mathieu"
newmdp =3D "test"

pMySQL =3D mysql_init(0)

If mysql_real_connect(pMySQL, "localhost", "root", "",
"gestion_droit", 0, "", 0) =3D 0 Then
MsgBox "la connexion a la base de donn=E9es a =E9chou=E9e"
Exit Sub
End If

test =3D mysql_query(pMySQL, "UPDATE gestion SET mdp =3D '" & newmdp & "'
WHERE Identifiant =3D '" & identif & "'")

mysql_close (pMySQL)


Le probleme c'est que je n'ai sais pas si le UPDATE a =E9t=E9 fait
correctement (j'ai essay=E9 d'afficher la varible test mais quoi qu'il
arrive, j'obtiens toujours "0")

Comment savoir si le UPDATE c'est fait correctement ?

Merci
Superman !

2 réponses

Avatar
jean-marc
> "Superman" wrote in message
news:
Bonjour,

Voici mon code :

Dim pMySQL As Long
dim test as integer
dim Identifiant as string
dim newmdp as string

Identifiant = "mathieu"
newmdp = "test"

pMySQL = mysql_init(0)

If mysql_real_connect(pMySQL, "localhost", "root", "",
"gestion_droit", 0, "", 0) = 0 Then
MsgBox "la connexion a la base de données a échouée"
Exit Sub
End If

test = mysql_query(pMySQL, "UPDATE gestion SET mdp = '" & newmdp & "'
WHERE Identifiant = '" & identif & "'")

mysql_close (pMySQL)


Le probleme c'est que je n'ai sais pas si le UPDATE a été fait
correctement (j'ai essayé d'afficher la varible test mais quoi qu'il
arrive, j'obtiens toujours "0")

Comment savoir si le UPDATE c'est fait correctement ?

Merci
Superman !



Hello,

comme dans toutes les DB, il y a une fonction qui permet
de connaitre le nombre de rows affectées par un statement.


Pour mysql, la syntaxe est décrite ici:
http://be.php.net/function.mysql-affected-rows


--
Jean-marc Noury (jean_marc_n2)
Microsoft MVP - Visual Basic
mailto: remove '_no_spam_' ;
FAQ VB: http://faq.vb.free.fr/
Avatar
Superman
Parfait ! Merci !