Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 466.7k

SqlException or binary data be truncated?

Jul 22 2020 9:29 AM
Hi Team
 
My save functionality is getting this exception, before all my form fields were saving to my table on DB. 
  1. // Controller  
  2.   
  3.         public ActionResult SubmitRegDetails(RegViewAndRoleViewModel eNtsaRegistration)  
  4.         {  
  5.              
  6.   
  7.             if(ModelState.IsValid)  
  8.             {  
  9.                 eNtsaRegistration.RegForm.Id = Guid.NewGuid();  
  10.                 db.eNtsaRegForms.Add(eNtsaRegistration.RegForm);  
  11.                 db.SaveChanges();  // Throws error here each time want to save changes to DB.
  12.                 return RedirectToAction("SaveRegForm");  
  13.             }  
  14.   
  15. // Model  
  16. public class eNtsaRegForm  
  17.     {  
  18.         [Key]  
  19.         public Guid? Id { getset; }  
  20.         public string Title { getset; }  
  21.         public string FirstName { getset; }  
  22.         public string LastName { getset; }  
  23.         public string Position { getset; }  
  24.         public string Company { getset; }  
  25.         public string StreetAddress { getset; }  
  26.         public string StreetAddressLine { getset; }  
  27.         public string City { getset; }  
  28.         public string StateProvince { getset; }  
  29.         public int ZipCode { getset; }  
  30.         public string Country { getset; }  
  31.   
  32.         [Required(ErrorMessage = " This field is required")]  
  33.         [EmailAddress(ErrorMessage = "Invalid email address")]  
  34.         public string Email { getset; }  
  35.           
  36.         public int CellNumber { getset; }  
  37.         public string DietaryRequirements { getset; }  
  38.   
  39.   
  40.     }  
 

Answers (7)