Picturebox and datagridview

0

I need help, I have uploaded images to bd, now I have the following problem: I put this code to select a row from the datagridview and populate the respective fields.

txtIDMovie.Text = dgvMovies.Rows[e.RowIndex].Cells[0].Value.ToString();
        txtNameMovie.Text = dgvMovies.Rows[e.RowIndex].Cells[1].Value.ToString();
        txtRealizador.Text = dgvMovies.Rows[e.RowIndex].Cells[2].Value.ToString();
        txtCatMovies.Text = dgvMovies.Rows[e.RowIndex].Cells[3].Value.ToString();
        txtAnoMovie.Text = dgvMovies.Rows[e.RowIndex].Cells[4].Value.ToString();
        txtClassIdade.Text = dgvMovies.Rows[e.RowIndex].Cells[5].Value.ToString();
        txtClassIMDB.Text = dgvMovies.Rows[e.RowIndex].Cells[6].Value.ToString();
        cbFormato.Text = dgvMovies.Rows[e.RowIndex].Cells[7].Value.ToString();

For the image I used:

            byte[] bytes = (byte[])dgvMovies.Rows[e.RowIndex].Cells[8].Value;
        MemoryStream ms = new MemoryStream(bytes);
        pbCapa.Image = Image.FromStream(ms);

Only if you want to edit a field that does not yet have an image when selecting the line gives error. Is there any way to resolve?

    
asked by anonymous 24.05.2017 / 22:38

1 answer

0

I tested it and it worked, the problem is that the database gets very slow. Is there another way to write without being an image?

    
01.06.2017 / 09:24