saving an image object in sql server database from action method
Posted
by
user3532152
on Stack Overflow
See other posts from Stack Overflow
or by user3532152
Published on 2014-05-26T21:22:54Z
Indexed on
2014/05/26
21:25 UTC
Read the original article
Hit count: 121
sql-server
|asp.net-mvc-4
[HttpPost]
public void Test(HttpPostedFileBase file) { UsersContext db = new UsersContext();
byte[] image = new byte[file.ContentLength];
file.InputStream.Read(image, 0, image.Length);
CrimeReport i = new CrimeReport
{
ImageId=1, ImageName="Anjli",ImageContent = image,
Active=true
};
db.CrimeReports.Add(i);
db.SaveChanges();
}
I am getting an exception on db.CrimeReports.Add(i);
© Stack Overflow or respective owner