给个链接,自已看吧
http://www.x5dj.com/UserForum/00100119/00005772.shtml

解决方案 »

  1.   

    一把有两种办法:1、存图片的连接地址:
       这种办法比较简单,主要针对比较大的图片。
    2、用Image字段存储:
       跟liujia_0421说的那样,先转成二进制流,然后再存库...取出时,将二进制流再转回来..
      

  2.   

    我的圖片也不多,頂多也是三兩張,現在用的數據庫是MYSQL的,有哪位兄弟有代碼的,開源看看
      

  3.   

    Sql Server 的例子
    ---------------------------------------------------------
    FileInfo fi = new FileInfo(this.strFileName);
    int imgdatalen=(int)fi.Length;
    imgdata = new byte[imgdatalen];
    Stream imgdatastream=fi.OpenRead();
    int n=imgdatastream.Read(imgdata,0,imgdatalen);
    string strInsert = "Insert MBInfor(FPic) values(@ImageData)";
    System.Data.SqlClient.SqlCommand cmdInsert = new System.Data.SqlClient.SqlCommand(strInsert,AccessDb.SQLConn);
    System.Data.SqlClient.SqlParameter paramImageData = new System.Data.SqlClient.SqlParameter("@ImageData",System.Data.SqlDbType.Image);
    paramImageData.Value = imgdata;
    cmdInsert.Parameters.Add(paramImageData);
    cmdInsert.ExecuteNonQuery();
      

  4.   

    读取
    --------------------------------------
    FileStream myStream = new FileStream("temp",FileMode.Create);
    byte[] mydata = ((byte[])this.dsMbinfor.Tables["MBInfor"].Rows[i]["FPic"]);//从数据库中读取的byte数组
    foreach(byte a in mydata)
    {
    myStream.WriteByte(a); 
    }
    Image myImage=Image.FromStream(myStream) ;
    myStream.Close();
      

  5.   

    不是非常必要,建议文件方式存放,数据库只存path