Merci pour ta réponse
Voilà la fonction que j'utilise
public byte[] PictureBoxImageToBytes(PictureBox picBox)
{
if ((picBox != null) && (picBox.Image != null))
{
Bitmap bmp = new Bitmap(picBox.Image);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Bmp);
byte[] buff = ms.ToArray();
ms.Close();
ms.Dispose();
return buff;
}
else
{
return null;
}
}
et ensuite
//Conversion de la photo en byte
byte[] v_Affiche = PictureBoxImageToBytes(PictBox_User);
try
{
//Insertion des données dans la table
FonctionsSGBD.ExecQuery
(
"INSERT INTO PERSONNE" +
" (PERS_NOM," +
" PERS_PRENOM," +
" PERS_ADRESSE," +
" PERS_CP," +
" PERS_VILLE," +
" PERS_TEL," +
" PERS_EMAIL," +
" PERS_IDENTIFIANT," +
" PERS_MDP," +
" PERS_PHOTO)" +
" VALUES " +
"(@Nom," +
" @Prenom," +
" @Adresse," +
" @CP," +
" @Ville," +
" @Tel," +
" @Email," +
" @Identifiant," +
" @MDP," +
" @Photo)",
new ParamProcStock("@Nom", tb_Nom.Text),
new ParamProcStock("@Prenom", tb_Prenom.Text),
new ParamProcStock("@Adresse", tb_Adresse.Text),
new ParamProcStock("@CP", maskedTb_CP.Text),
new ParamProcStock("@Ville", tb_Ville.Text),
new ParamProcStock("@Tel", maskedTb_Tel.Text),
new ParamProcStock("@Email", v_email),
new ParamProcStock("@Identifiant", tb_Identifiant.Text),
new ParamProcStock("@MDP", tb_MDP.Text),
new ParamProcStock("@Photo", v_Affiche)
);
MessageBox.Show("Nouvel utilisateur créé avec succès", "Information", MessageBoxButtons.OK);
Close();
}
Pour la ressortir, j'utilise un bindingsource que je configure et une picturebox. Dans la picturebox, au niveau des databindings, j'appelle le bindingsource