【求助】sql保存图片的问题
理想效果:listbox1里面是person_id号,选中哪个在picturebox里就有对应图片,单机更新button,从电脑里选一张图片,就能保存
我的实际效果:数据库只有ID号,还没有保存图片任何,数据库图片是image类型,运行这个程序之后,每次在opendialogfile里选图之后,点打开,随后又出现一次opendialogfile界面,还得选,再点击打开,系统就报错,求助!很着急
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
         {
             ShowImage();
         }
private void ShowImage()
         {
             if (this.pictureBox9 != null)
                 this.pictureBox9.Image.Dispose();
             if(ds.Tables[0].Rows[this.listBox1.SelectedIndex][1]!=Convert.DBNull)
             {
                 byte[] bytes = (byte[])ds.Tables[0].Rows[this.listBox1.SelectedIndex][1];
                 MemoryStream memStream = new MemoryStream();
                 Bitmap myImage = new Bitmap(memStream);
                 this.pictureBox9.Image = myImage;
             }
             else
             {
                 this.pictureBox9.Image = null;
             }
         }
private void button更新_Click(object sender, EventArgs e)
         {
             openFileDialog1.Filter = "*.jpg,*.jepg,*.bmp,*.gif,*.ico,*.png,*.tif,*.wmf;*.*|*.jpg;*.jepg;*.bmp;*.gif;*.ico;*.png;*.tif;*.wmf;*.*";
             this.openFileDialog1.ShowDialog();
             if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 Stream myStream = openFileDialog1.OpenFile();
                 int Length = (int)myStream.Length;
                 byte[] bytes = new byte[Length];
                 myStream.Read(bytes, 0, Length);
                 myStream.Close();
                 ds.Tables[0].Rows[this.listBox1.SelectedIndex][9] = bytes;
                 try
                 {
                     ad.Update(ds.Tables[0]);
                     MessageBox.Show("保存成功!");
                     //OwnerPic = openFileDialog1.FileName;
                     //pictureBox9.Image = Image.FromFile(OwnerPic);
                 }
                 catch (Exception err)
                 {
                     MessageBox.Show(err.Message, "保存失败");
                 }
                 ShowImage();
             }
         }
------解决方案--------------------
C#在SQl中存取图片image
------解决方案--------------------
写了两个
C# code
this.openFileDialog1.ShowDialog();