下面是保存
string MyInsert = "Insert Into Product_Info(Top_Pic) values(@Top_Pic)";
SqlCommand MyCommand = new SqlCommand(MyInsert, conn);
pict_Top.Image.Save(pict_top_filename); // pict_Top是picturebox控件,pict_top_filename是图片文件的文件名
FileStream fs = new FileStream(pict_top_filename, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] pict_top_pict = br.ReadBytes((int)fs.Length);
MyCommand.Parameters.Add(new SqlParameter("@Top_Pic", SqlDbType.Image));//准备把二进制的图片存到数据库里面
MyCommand.Parameters["@Top_Pic"].Value = pict_top_pict;
MyCommand.ExecuteNonQuery();//执行保存
下面读取
MemoryStream stream_pic_top = new MemoryStream(pict_top_pict); //图片文件的文件名
Image pic_top_pp = Image.FromStream(stream_pic_top);
dataGridView_product.Rows[rows].Cells[8].Value = pic_top_pp ;//把内存中的图片显示到datagridview空间中
希望有所帮助!!