Bonjour,
Je développe une application en C# / MySQL.
Le problème, lorsque j'entre dans un champs un nom qui contient un caractère spécial, comme l'Apstrophe, le ( &é"'(-è_çà)=, alors l'application bug
Version imprimable
Bonjour,
Je développe une application en C# / MySQL.
Le problème, lorsque j'entre dans un champs un nom qui contient un caractère spécial, comme l'Apstrophe, le ( &é"'(-è_çà)=, alors l'application bug
Bonjour,
On peut en savoir un peu plus sur ce qui "bug" ?
Y a-t-il un message d'erreur renvoyé ? Si oui, lequel ?
Quel est la requête qui est envoyée à la base de données (le problème peut très bien se situer côté C#, auquel cas ce forum n'est pas le bon pour poser la question).
Avec comme seule indication : "ça bug", on ne peut pas grand chose pour vous aider :?
ced
ok je comprend le message d'erreur et le suivant
Pièce jointe 61347
Et on peut voir la requête complète qui génère cette erreur ?
ced
bonjour voici la requete
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 public bool MAJ(int id) { DataBase bd = new DataBase(); try { MySQLCommand cmd = new MySQLCommand("UPDATE Client SET NoStatut='"+this._NoStatut.ToString()+"',NoFonction='"+this._NoFonction.ToString()+"',NoNiveau='"+this._NoNiveau.ToString()+"',Nom='"+this._Nom.ToString()+"',Prenom='"+this._Prenom.ToString()+"',Nationalite='"+this._Nationalite.ToString()+"',CIN='"+this._CIN.ToString()+"',Age='"+this._Age.ToString()+"',Adresse='"+this._Adresse.ToString()+"',CP='"+this._CP.ToString()+"',Pays='"+this._Pays.ToString()+"',TelFix='"+this._TelFix+"',TelGSM='"+this._TelGSM+"',Email='"+this._Email.ToString()+"',com='"+this._Com.ToString()+"',Ville='"+this._Ville.ToString()+"' WHERE isInscrit=0 and NoClient='"+id.ToString()+"'",bd.Connection()); MySQLDataReader reader = cmd.ExecuteReaderEx(); cmd.Dispose(); return true; } catch(Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); return false; } }
Bonsoir.
Je ne code pas en C# mais le problème vient peut être du fait qu'il y a une ambiguïté avec les simple quote du contenu du champs que tu essayes de stocker en base. Je n'en suis pas certain mais il faut peut être échapper ces simple quote avec un carractère d'échappement spécifique au langage ('\' non ?) ... Regardes s'il existe un équivalent en C# de la fonction addslashes en PHP (ou code la toi même :mouarf:).
Cordialement,
Idriss
Désolé, je n'ai pas été suffisamment clair.
Quand je dis "afficher la requête", ce n'est pas afficher le code C# qui génère la requête, mais plutôt afficher la chaîne de caractère issue de l'exécution de ce code et qui correspond à la requête qui est passée au serveur MySQL.
En clair, peux-tu nous donner un "print" de la chaîne suivante :
Je ne connais pas du tout C#, mais qu'est-ce qui s'affiche si tu fais, avant l'exécution de la requête la commande suivante :Code:"UPDATE Client SET NoStatut='"+this._NoStatut.ToString()+"',NoFonction='"+this._NoFonction.ToString()+"',NoNiveau='"+this._NoNiveau.ToString()+"',Nom='"+this._Nom.ToString()+"',Prenom='"+this._Prenom.ToString()+"',Nationalite='"+this._Nationalite.ToString()+"',CIN='"+this._CIN.ToString()+"',Age='"+this._Age.ToString()+"',Adresse='"+this._Adresse.ToString()+"',CP='"+this._CP.ToString()+"',Pays='"+this._Pays.ToString()+"',TelFix='"+this._TelFix+"',TelGSM='"+this._TelGSM+"',Email='"+this._Email.ToString()+"',com='"+this._Com.ToString()+"',Ville='"+this._Ville.ToString()+"' WHERE isInscrit=0 and NoClient='"+id.ToString()+"'"
?Code:System.Windows.Forms.MessageBox.SHOW("UPDATE Client SET NoStatut='"+this._NoStatut.ToString()+"',NoFonction='"+this._NoFonction.ToString()+"',NoNiveau='"+this._NoNiveau.ToString()+"',Nom='"+this._Nom.ToString()+"',Prenom='"+this._Prenom.ToString()+"',Nationalite='"+this._Nationalite.ToString()+"',CIN='"+this._CIN.ToString()+"',Age='"+this._Age.ToString()+"',Adresse='"+this._Adresse.ToString()+"',CP='"+this._CP.ToString()+"',Pays='"+this._Pays.ToString()+"',TelFix='"+this._TelFix+"',TelGSM='"+this._TelGSM+"',Email='"+this._Email.ToString()+"',com='"+this._Com.ToString()+"',Ville='"+this._Ville.ToString()+"' WHERE isInscrit=0 and NoClient='"+id.ToString()+"'")
ced