如题;数据库是Sql Server,里有二进制的字段 ,怎样对这个字段进行读和写的操作,最好有code参考一下
非常谢谢

解决方案 »

  1.   

    数据库中的binary型的数据,在.net中是用string来显示
      

  2.   

    binary类型的数据直接读出来显示就可以吗?显示的是乱码的
    怎么写呢?
      

  3.   

    是把数据转换成byte[]数据写进去
      

  4.   

    System.Text.Encoding.UTF8.GetString(CType(BinColValue, Byte()))
    试一下你在.net版里搜索一下,好多类似的帖子
      

  5.   

    参考
    =======================================
    转为byte类型后存入Image字段。
    byte[] imagebytes=null;
    FileStream fs=new FileStream(Image_path,FileMode.Open);
    BinaryReader br=new BinaryReader(fs);
    imagebytes=br.ReadBytes(br.Length);
    SqlParameter parInput22=cmd.Parameters.Add("@员工图片",SqlDbType.Image);
    parInput22.Direction=ParameterDirection.Input;
    cmd.Parameters["@员工图片"].Value=imagebytes;
    cmd.ExecuteNonQuery();
    数据库中操作图片
    How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;309158