比如:表mytable中有一个字段A,类型为binary[20],
我有一个byte[] bytes = new byte[20]
bytes[0]=0x1;
bytes[1]=0xb
...我想用
update mytable set ...where id=1更新语句然后想用sqlcommand实现,而不想通过传参数的实现.

解决方案 »

  1.   

    转为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
    DataGrid显示图片(物理路径式和Stream流式)和添加图片到数据库
    http://singlepine.cnblogs.com/articles/288027.html