那位大侠帮助指点一下。
  string fullpath = FileUpload1.PostedFile.FileName;
            FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read);
            byte[] imagebytes = new byte[fs.Length];
            BinaryReader br = new BinaryReader(fs);
            imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));//把所选图片文件的流中的数据读入字节数组             SQL = "Insert into XXXX_Image (PsnImage) Values ('" +imagebytes + "') ";            

解决方案 »

  1.   

    我在网上找的方法,在执行上面的SQL语句后,不管图片的大小、内容是什么,数据库中PsnImage(image类型)都是为“0x53797374656D2E427974655B5D”,而且也显示不出图片。
      

  2.   

    存为image类型就是byte.读取出来的时候也是byte.需要手工转成图片.
    还是建议存储为文件.减少数据库体积
      

  3.   

    参数化  SqlConnection conn = new SqlConnection(ConStr);
      string strSql = "insert into Hospital_Employees(EmpNum,EmpName,EmpFingerTmp)    values(@EmpNum,@EmpName,@EmpFingerTmp)";
    SqlCommand cmd = new SqlCommand(strSql, conn);  cmd.Parameters.Add("@EmpFingerTmp", SqlDbType.Binary);
      cmd.Parameters["@EmpFingerTmp"].Value = imagebytes;
      conn.Open();
      cmd.ExecuteNonQuery();
      conn.Close();
      

  4.   

            private string ConvertBytesToString(byte[] bytes)
            {
                StringBuilder sb = new StringBuilder();
                foreach (byte b in bytes)
                {
                    string sby = Convert.ToString(b, 16);                if (sby.Length == 1)
                    {
                        sby = "0" + sby;
                    }
                    sb.Append(sby);
                }
                return sb.ToString();
            }  string fullpath = FileUpload1.PostedFile.FileName;
       FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read);
       byte[] imagebytes = new byte[fs.Length];
       BinaryReader br = new BinaryReader(fs);
       imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));//把所选图片文件的流中的数据读入字节数组    SQL = "Insert into XXXX_Image (PsnImage) Values (0x" + ConvertBytesToString(imagebytes) + ") ";
    至于显示,参考以下链接:
    http://blog.csdn.net/lsd123/article/details/3655370