This action method is uploading the image, when it executes dbx.SaveChanges(); method then it throws the exception. "String or binary data would be truncated. The statement has been terminated"
public ActionResult FileUpload(int id, HttpPostedFileBase file)
{
dbCRMEntities dbx = new dbCRMEntities();
CONTACT con = new CONTACT();
if (file != null)
{
string pic = System.IO.Path.GetFileName(file.FileName);
string path = System.IO.Path.Combine(
Server.MapPath("~/Content/Images"), pic);
// file is uploaded
file.SaveAs(path);
//con.NAME = path;
con = dbx.CONTACTS.FirstOrDefault(Id => id == Id.CONTACT_ID);
con.IMAGE = path;
dbx.SaveChanges();
}
return RedirectToAction("Index", "Home");
}
Here image is type of string for storing the path. Please guide what changes should I make?