Farhad.idrees 1 Junior Poster in Training

Hi i have database whicho store images in binary..
now i want to show image in picture box when someone click on datagrid..
i have following code..

  private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                //retreive picture from database
                int iIndex = dataGridView1.CurrentCell.RowIndex;
                DataGridViewCell cell_index = dataGridView1[8, iIndex];
                byte[] b = (byte[])cell_index.Value;
                MemoryStream streamm = new MemoryStream(b);
                pictureBox1.Image = Image.FromStream(streamm);
            }
            catch
            {
            }

when i scroll so exception come and the error is about to handle dataerror..
what should i do now..
regards...
Farhad

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.