Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Team

I have a method on my controller to save fields from the form. But its throwing this error each time. I need some help mates to resolve it, thanks.

What I have tried:

C#
// Controller
<pre>  //GET:TrainingRegForm/Create/WebRequest.
        [HttpPost]
       
        public ActionResult SubmitRegDetails(RegViewAndRoleViewModel eNtsaRegistration)
        {
           

            if(ModelState.IsValid)
            {
                eNtsaRegistration.RegForm.Id = Guid.NewGuid();
                db.eNtsaRegForms.Add(eNtsaRegistration.RegForm);
                db.SaveChanges();
                return RedirectToAction("SaveRegForm");
            }
            return View(eNtsaRegistration);
            
        }


// DB columns fields with data types
ID(uniqueidentifier not null) PK
Title nvarchar(10) not null
FirstName nvarchar(15) not null
LastName nvarchar(25) not null
Position nvarchar(15) not null
Company nvarchar(35) not null
StreetAddress nvarchar(Max)) not null
StreetAddressLine nvarchar(Max))
City nvarchar(35) not null
StateProvince nvachar(45) not null
ZipCode int not null
Country nvarchar(30) not null
Email nvarchar(30) not null
CellNumber int not null
DietaryRequirement nvarchar(10) not null
Posted
Updated 23-Jul-20 0:28am

Exactly the same as the explanation you were given yesterday: Sqlexceptionbinary or data be truncated?[^]. You cannot squeeze 100 characters into a field that will only hold 50.
 
Share this answer
 
I told you yesterday what the two solutions were: Sqlexceptionbinary or data be truncated? - Solution 1[^]
Quote:
There are only two fixes for this:
1) Reduce the size of the string.
Or
2) Increase the column size.

And that will not change no matter how many times you ask the same question!
Another thing that won't change:
Quote:
We can't do either of those for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900