FileStream fs = new FileStream(url, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] photo = br.ReadBytes((int)fs.Length);
Modulecs.Emap.Upd_maplampimg(id, photo, image);
public static int 写入图片到数据库(string id, byte[] byte,string type)
{
using (SqlConnection conn = new SqlConnection(onnString))
{
//INSERT INTO Picture (PictureContent, PictureText) VALUES (@Picture,'Test')
SqlCommand comm = new SqlCommand();
conn.Open();
comm.Connection = conn;
comm.CommandText = string.Format("update 表名称 set image=@Picture,where id='{1}'", id);
comm.CommandType = CommandType.Text;
comm.Parameters.Add("@Picture", System.Data.SqlDbType.Image, by.Length).Value = byte
;
return comm.ExecuteNonQuery();
}
}
//image文件转换
public static byte[] bytes(string url,string image)
{
FileStream fs = new FileStream(url, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] photo = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
return photo;
}