try 
                    {
                        MemoryStream ms = new MemoryStream ();
                        picPhoto.Image.Save (ms, System.Drawing.Imaging.ImageFormat.Bmp);
                        byte [] myData = new Byte [ms.Length ];
                        ms.Position = 0;
                        ms.Read (myData,0,Convert.ToInt32 (ms.Length ));
                        m_DataRow[MyTools.g_PhotoField] = myData;                    }
                    catch(System.Exception ee) 
                    {
                        MessageBox.Show(ee.Message);
                    }                                                   wish u good luck
                                                        Greatsft

解决方案 »

  1.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=J9UBRVER-L3VB-49M3-GOU1-Z6C2PVR6FZ3K
      

  2.   

    to:greatsft(C的使者)插入的图片又怎么读取并显示在picturebox中呢?
      

  3.   

    读取图象:
     try
                        {
                            Byte[] byteBLOBData =  new Byte[0];
                            byteBLOBData = (Byte[])m_DataRow[MyTools.g_PhotoField];
                            MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
                            this.picPhoto.Image= Image.FromStream(stmBLOBData);
                        }
                        catch(Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
      

  4.   

    SqlConnection conn=new SqlConnection(@"data source=chenyuming2004\VSdotNET;uid=sa;pwd=cym;database=lhf");
    conn.Open();
    SqlCommand cmd=new SqlCommand("insert into fuser values ('1a','1b',@i)",conn);
    byte[] ib=new Byte[60000];
    FileStream fs=new FileStream(@"D:\windows temp\temp\1.jpg",FileMode.Open ,FileAccess.Read );
    fs.Read(ib,0,60000);
    cmd.Parameters.Add("@i",SqlDbType.Image,(int)fs.Length);
    cmd.Parameters["@i"].Value=ib;
    cmd.ExecuteNonQuery();
    conn.Close();
    把图片读到pictureBox,再写入数据库
      

  5.   

    SqlConnection conn=new SqlConnection(@"data source=chenyuming2004\VSdotNET;uid=sa;pwd=cym;database=lhf");
    conn.Open();
    SqlCommand cmd=new SqlCommand("select 照片 from fuser where password='1b'",conn);
    SqlDataReader reader=cmd.ExecuteReader();
    reader.Read();
    MemoryStream buf=new MemoryStream((byte[])reader[0]);
    Image image=Image.FromStream(buf,true);
    pictureBox1.Image=image;
    从数据库读图片到picturebox