http://www.programfan.com/showarticle.asp?id=2105

解决方案 »

  1.   

    http://home.jlu.edu.cn/~hoofi/dbbase/603565.xml
      

  2.   

    下面是我的程序片断
    //保存图片
    if(this.bImageChanged)
    {
    try 
    {
    MemoryStream ms = new MemoryStream ();
    this.picImage.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 ));
    myDataRow["缩略图"] = myData; }
    catch(System.Exception ee) 
    {
    MessageBox.Show(ee.Message);
    }

    }
    this.bImageChanged=false;
    return true;
    }
    //显示缩略图
    if(this.myDataRow["缩略图"]!=DBNull.Value)
    {
    try
    {
    Byte[] byteBLOBData =  new Byte[0];
    byteBLOBData = (Byte[])myDataRow["缩略图"];
    MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
    this.picImage.Image= Image.FromStream(stmBLOBData);
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }
    this.picImage.Refresh();
      

  3.   

    DataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
    FileInfo aFile = new FileInfo(@""+directory);
    if (!aFile.Exists)
    {
    MessageBox.Show("请检查相片文件:"+Field+"路径名:"+directory+"是否正确?", "输入错误,文件不存在!", MessageBoxButtons.OK, MessageBoxIcon.Question);
    return;
    }
    //===========处理文件的格式,如果不是正确格式,报错。
    Image i = Image.FromFile(directory); FileStream  fs;
    /*if (i.Size.Height != 168 || i.Size.Width != 104)
    {
    //===========处理图片缩小功能
    System.Drawing.Image image = new Bitmap(aFile.FullName);//得到原图
    System.Drawing.Image pThumbnail = image.GetThumbnailImage(168, 104, null, new IntPtr());  //创建缩小的图的大小
    Graphics g=Graphics.FromImage(pThumbnail);
    g.DrawImage(pThumbnail,10,10, pThumbnail.Width, pThumbnail.Height); //将原图画到缩小的图上
    pThumbnail.Save(@"C:\WINNT\Temp\a.Jpeg",ImageFormat.Jpeg);  //保存
    g.Dispose();
    fs = new FileStream (@"C:\WINNT\Temp\a.Jpeg" , FileMode.OpenOrCreate, FileAccess.Read);
    }
    else
    {
    fs = new FileStream (@"" + directory , FileMode.OpenOrCreate, FileAccess.Read);
    }*/
    fs = new FileStream (@"" + directory , FileMode.OpenOrCreate, FileAccess.Read);
    //==================读文件并存储到数据库中
    byte[] MyData= new byte[fs.Length];
    fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
    tempDatarow[""+Field] = MyData; System.IO.MemoryStream stream = new System.IO.MemoryStream(MyData, true);
    stream.Write(MyData, 0, MyData.Length); Bitmap bmp = new Bitmap(stream); if( bmp.Width != 168 && bmp.Height != 104)
    {
    Bitmap bmp1 = new Bitmap(bmp, new Size(168,104));
    picture.Image = bmp1;
    }
    else
    picture.Image = bmp;
    stream.Close(); fs.Close();
    //=================删除临时文件。
    /*if (System.IO.File.Exists(@"C:\WINNT\Temp\a.Jpeg"))
    {
    System.IO.File.Delete(@"C:\WINNT\Temp\a.Jpeg");
    }*/
      

  4.   

    http://expert.csdn.net/Expert/topicview.asp?id=1690497
      

  5.   

    http://www.codeproject.com/cs/database/albumviewer.asp
    电子像册,sqlServer