Salut !
J'ai un Datagrid qui m'affiche ce qu'il y a dans ma BD.
Mais le hic c'est que il n'y a pas d'image et et la valeur de BLOB est NULL,
je me tape ce jolie message d'erreur quand je clique sur mon DataGrid
'System.DBNull' en type 'System.Byte[]'.
Comment puis je faire un If pour cette commande.
Je laisse mon code sa m'aidera pour les prochains
Merci d'avance.....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 If e.RowIndex >= 0 Then Dim row As DataGridViewRow row = Me.DataGridView1.Rows(e.RowIndex) TextBox2.Text = row.Cells("nombre").Value.ToString TextBox3.Text = row.Cells("apellidos").Value.ToString TextBox4.Text = row.Cells("dni").Value.ToString TextBox5.Text = row.Cells("calle").Value.ToString TextBox6.Text = row.Cells("poblacion").Value.ToString TextBox7.Text = row.Cells("cp").Value.ToString TextBox8.Text = row.Cells("provincia").Value.ToString TextBox9.Text = row.Cells("nacionalidad").Value.ToString DateTimePicker1.Text = row.Cells("fecha_nacimiento").Value.ToString TextBox10.Text = row.Cells("lugar_nacimiento").Value.ToString DateTimePicker2.Text = row.Cells("fecha_entrada").Value.ToString DateTimePicker3.Text = row.Cells("fecha_baja").Value.ToString DateTimePicker4.Text = row.Cells("fecha_baja_definitiva").Value.ToString ComboBox1.Text = row.Cells("empresa").Value.ToString ComboBox2.Text = row.Cells("lugar_trabajo").Value.ToString ComboBox3.Text = row.Cells("puesto").Value Dim data As Byte() = row.Cells("foto").Value Dim ms As New MemoryStream(Data) PictureBox1.Image = Image.FromStream(MS) End If
Partager