How to retrieve image from database in c#

前端 未结 2 973
滥情空心
滥情空心 2020-12-22 01:02

an error shows saying that I have invalid parameters for this code... can anyone tell me whats wrong? Im supposed to get the image assigned to the clientID.

         


        
2条回答
  •  旧巷少年郎
    2020-12-22 01:40

    This piece of code might come in handy. I have tried it.

    byte[] imagedata = (byte [])dataGridView1[4, dataGridView1.SelectedRows[0].Index].Value;
                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(imagedata, 0, imagedata.Length))
                {
                    ms.Write(imagedata, 0, imagedata.Length);
                    //Set image variable value using memory stream.
                    image = Image.FromStream(ms, true );
                }
    

提交回复
热议问题