请问,怎么把一整张图片存到数据库中的一个字段里?  我用的是c#和sql 谁能举个简单的例子吗?谢谢

解决方案 »

  1.   

    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=185154
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6404
      

  2.   

    把图片读成MemoryStream,写入Sql server的image类型的字段
      

  3.   

    /// <summary>
     /// 根据文件路径及名称获取该文件的流
     /// </summary>
     /// <param name="filePathName">文件路径及名称</param>
     /// <returns>返回Byte[]</returns>
     private Byte[] get_Byte(string filePathName)
     {
      //以二进制方式读取该文件,并写到Byte[]里面
      System.IO.FileStream myfs = new System.IO.FileStream(filePathName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
      Byte[] Buffer = new byte[myfs.Length];
      myfs.Read(Buffer,0,Buffer.Length);
      return(Buffer);
     }