I am working with Windows Form Application and I have SQL Database with table members and the columns: id, fname, lname, gender, telephone, created, email and picture (the pictures are saved . I am using bound DataGrid with all the columns except the id column. I want the picturebox to show the image from the selected row, I tried everything that I found online but nothing.
This is the table query:
CREATE TABLE [dbo].[members](
[id] [int] IDENTITY(1,1) NOT NULL,
[fname] [varchar](50) NOT NULL,
[lname] [varchar](50) NOT NULL,
[gender] [varchar](10) NOT NULL,
[telephone] [varchar](20) NOT NULL,
[created] [date] NULL,
[picture] [image] NULL,
[email] [varchar](50) NULL,
CONSTRAINT [PK__members__3213E83F00551192] PRIMARY KEY CLUSTERED
And this is the code for showing the columns:
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
nameText.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
lnameText.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
genderText.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
telephoneText.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
datecreaText.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
emailText.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
var data = (Byte[])(row.Cells[6].Value);
var stream = new MemoryStream(data);
pictureBox1.Image = Image.FromStream(stream);
Can someone help me 3 days into this problem and I can't solve it.