-1

I have an ASP.NET FX application hosted on an IIS server. On the server, and only on the server, not in Visual Studio IIS Express, when loading the 'Create' page I get this error:

Exception thrown: 'System.NullReferenceException' in System.Web.Mvc.dll

enter image description here

Usually 28 times. The errors below that occur when trying to create a new record (the POST method) but gives just as little information as the first error. I have VS Remote debugging configured for the server.

Create Get method

// GET: Statewides/Create
        public ActionResult Create()
        {
            return View();
        }

Create Post method

[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "ID,COUNTY,SignSys,RouteNoOrigImport,RouteNo,SuppDes,LocalName,DateNumber,Method,OriginalL,OriginalD,Projects,Documents,Comments,District,Duplicate_OK,RightofWay,ReservedRoute,ReservedBy,ReservedDate,CP_WorkCompleted,Work_Comments,CP_ProjectNo,ReservedCat,CurrentStatus,Add_User,Date_Added")] Statewide statewide)
        {
            if (ModelState.IsValid)
            {
                var userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                statewide.Add_User = userName;
                statewide.Date_Added = DateTime.Today;
                db.Statewides.Add(statewide);
                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                        }
                    }
                }
                int lastAddedID = db.Statewides.Max(item => item.ID);
                return RedirectToAction("Create", "Documents", new { statewideID = lastAddedID});
            }

            return View(statewide);
        }

With the try catch block the code runs fine but no record is added to the database. Just nothing happens. The page simply navigates to the next page without adding a database record.

Without the try catch block simply using db.SaveChanges(); the app crashes and I get the errors:

Exception thrown: 'System.Data.Entity.Validation.DbEntityValidationException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Validation.DbEntityValidationException' in System.Web.Mvc.dll
Exception thrown: 'System.Data.Entity.Validation.DbEntityValidationException' in System.Web.Mvc.dll

I don't find these errors very helpful. I have no idea what the problem is. The errors don't point to any line or any particular variable or object so I have no idea where the problem is. I also don't understand why the try catch block simply ignores these errors.

What can I do to get a better error message?

EDIT: I tried to add the code that was recommended in the comments like this:

     catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                            if(ex.InnerException != null)
                            {
                                Response.Write(ex.InnerException.Message);
                            }
                        }
                    }
                }

But there were no changes.

EDIT 2:

Create View

@model Roadway_History.Models.Statewide

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>


@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
<div class="form-horizontal">
    <h4>Statewide</h4>
    <hr />
    <div class="form-group">
        @Html.LabelFor(model => model.COUNTY, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownList("COUNTY", new List<SelectListItem>
            {
                new SelectListItem {Text = "BARBOUR", Value="BARBOUR"  },
                new SelectListItem {Text = "BERKELEY", Value="BERKELEY"  },
                new SelectListItem {Text = "BOONE", Value="BOONE"  },
                new SelectListItem {Text = "BRAXTON", Value="BRAXTON"  },
                new SelectListItem {Text = "BROOKE", Value="BROOKE"  },
                new SelectListItem {Text = "CABELL", Value="CABELL"  },
                new SelectListItem {Text = "CALHOUN", Value="CALHOUN"  },
                new SelectListItem {Text = "CLAY", Value="CLAY"  },
                new SelectListItem {Text = "DODDRIDGE", Value="DODDRIDGE"  },
                new SelectListItem {Text = "FAYETTE", Value="FAYETTE"  },
                new SelectListItem {Text = "GILMER", Value="GILMER"  },
                new SelectListItem {Text = "GRANT", Value="GRANT"  },
                new SelectListItem {Text = "GREENBRIER", Value="GREENBRIER"  },
                new SelectListItem {Text = "HAMPSHIRE", Value="HAMPSHIRE"  },
                new SelectListItem {Text = "HANCOCK", Value="HANCOCK'"  },
                new SelectListItem {Text = "HARDY", Value="HARDY"  },
                new SelectListItem {Text = "HARRISON", Value="HARRISON"  },
                new SelectListItem {Text = "JACKSON", Value="JACKSON"  },
                new SelectListItem {Text = "JEFFERSON", Value="JEFFERSON"  },
                new SelectListItem {Text = "KANAWHA", Value="KANAWHA"  },
                new SelectListItem {Text = "LEWIS", Value="LEWIS"  },
                new SelectListItem {Text = "LINCOLN", Value="LINCOLN"  },
                new SelectListItem {Text = "LOGAN", Value="LOGAN"  },
                new SelectListItem {Text = "MCDOWELL", Value="MCDOWELL"  },
                new SelectListItem {Text = "MARION", Value="MARION"  },
                new SelectListItem {Text = "MARSHALL", Value="MARSHALL"  },
                new SelectListItem {Text = "MASON", Value="MASON"  },
                new SelectListItem {Text = "MERCER", Value="MERCER"  },
                new SelectListItem {Text = "MINERAL", Value="MINERAL"  },
                new SelectListItem {Text = "MINGO", Value="MINGO"  },
                new SelectListItem {Text = "MONONGALIA", Value="MONONGALIA"  },
                new SelectListItem {Text = "MONROE", Value="MONROE"  },
                new SelectListItem {Text = "MORGAN", Value="MORGAN"  },
                new SelectListItem {Text = "NICHOLAS", Value="NICHOLAS"  },
                new SelectListItem {Text = "OHIO", Value="OHIO"  },
                new SelectListItem {Text = "PENDLETON", Value="PENDLETON"  },
                new SelectListItem {Text = "PLEASANTS", Value="PLEASANTS"  },
                new SelectListItem {Text = "POCAHONTAS", Value="POCAHONTAS"  },
                new SelectListItem {Text = "PRESTON", Value="PRESTON"  },
                new SelectListItem {Text = "PUTNAM", Value="PUTNAM"  },
                new SelectListItem {Text = "RALEIGH", Value="RALEIGH'"  },
                new SelectListItem {Text = "RANDOLPH", Value="RANDOLPH"  },
                new SelectListItem {Text = "RITCHIE", Value="RITCHIE"  },
                new SelectListItem {Text = "ROANE", Value="ROANE"  },
                new SelectListItem {Text = "SUMMERS", Value="SUMMERS"  },
                new SelectListItem {Text = "TAYLOR", Value="TAYLOR"  },
                new SelectListItem {Text = "TUCKER", Value="TUCKER"  },
                new SelectListItem {Text = "TYLER", Value="TYLER"  },
                new SelectListItem {Text = "UPSHUR", Value="UPSHUR"  },
                new SelectListItem {Text = "WAYNE", Value="WAYNE"  },
                new SelectListItem {Text = "WEBSTER", Value="WEBSTER"  },
                new SelectListItem {Text = "WETZEL", Value="WETZEL"  },
                new SelectListItem {Text = "WIRT", Value="WIRT"  },
                new SelectListItem {Text = "WOOD", Value="WOOD"  },
                new SelectListItem {Text = "WYOMING", Value="WYOMING"  }
            }, new { @class = "form-control" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.SignSys, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownList("SignSys", new List<SelectListItem>
            {
                new SelectListItem {Text = "CO", Value="CO"  },
                new SelectListItem {Text = "US", Value="US"  },
                new SelectListItem {Text = "WV", Value="WV"  },
                new SelectListItem {Text = "DE", Value="DE"  },
                new SelectListItem {Text = "P&F", Value="P&F"  },
                new SelectListItem {Text = "HA", Value="HA"  },
                new SelectListItem {Text = "ZMISC", Value="ZMISC"  },
                new SelectListItem {Text = "I", Value="I"  },
                new SelectListItem {Text = "PR", Value="PR"  },
                new SelectListItem {Text = "MNS", Value="MNS"  },
                new SelectListItem {Text = "USFS", Value="USFS"  }
            }, new { @class = "form-control" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.RouteNoOrigImport, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.RouteNoOrigImport, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.RouteNoOrigImport, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.RouteNo, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.RouteNo, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.RouteNo, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.SuppDes, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownList("SuppDes", new List<SelectListItem>
            {
                new SelectListItem {Text = "Not Applicable", Value="00"  },
                new SelectListItem {Text = "Alternate", Value="01"  },
                new SelectListItem {Text = "Wye", Value="02"  },
                new SelectListItem {Text = "Spur", Value="03"  },
                new SelectListItem {Text = "North", Value="04"  },
                new SelectListItem {Text = "South", Value="05"  },
                new SelectListItem {Text = "East", Value="06"  },
                new SelectListItem {Text = "West", Value="07"  },
                new SelectListItem {Text = "Business", Value="08"  },
                new SelectListItem {Text = "North Bound", Value="09"  },
                new SelectListItem {Text = "South Bound", Value="10"  },
                new SelectListItem {Text = "East Bound", Value="11"  },
                new SelectListItem {Text = "West Bound", Value="12"  },
                new SelectListItem {Text = "Truck Route", Value="13"  },
                new SelectListItem {Text = "Bypass", Value="14"  },
                new SelectListItem {Text = "Loop", Value="15"  },
                new SelectListItem {Text = "Toll", Value="16"  },
                new SelectListItem {Text = "Ramp", Value="17"  },
                new SelectListItem {Text = "Other", Value="18"  },
                new SelectListItem {Text = "City St. Non-State", Value="19"  },
                new SelectListItem {Text = "Road Under Construction", Value="20"  },
                new SelectListItem {Text = "Footbridge", Value="21"  },
                new SelectListItem {Text = "Historical Bridge", Value="22"  },
                new SelectListItem {Text = "Connector", Value="23"  },
                new SelectListItem {Text = "New/Proposed", Value="24"  },
                new SelectListItem {Text = "Crossover", Value="25"  },
                new SelectListItem {Text = "Emergency Crossover", Value="26"  },
                new SelectListItem {Text = "Left Turn Lane", Value="27"  },
                new SelectListItem {Text = "Right Turn Lane", Value="28"  },
                new SelectListItem {Text = "Rail Trail", Value="51"  },
                new SelectListItem {Text = "Abandoned", Value="99"  }
            }, new { @class = "form-control" })
        </div>
    </div>



    <div class="form-group">
        @Html.LabelFor(model => model.LocalName, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.LocalName, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.LocalName, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.DateNumber, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.DateNumber, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.DateNumber, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Method, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Method, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Method, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.OriginalL, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.OriginalL, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.OriginalL, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.OriginalD, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.OriginalD, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.OriginalD, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Projects, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Projects, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Projects, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Documents, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Documents, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Documents, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Comments, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Comments, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Comments, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.District, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.District, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.District, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Duplicate_OK, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <div class="checkbox">
                @Html.EditorFor(model => model.Duplicate_OK)
                @Html.ValidationMessageFor(model => model.Duplicate_OK, "", new { @class = "text-danger" })
            </div>
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.RightofWay, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.RightofWay, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.RightofWay, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ReservedRoute, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <div class="checkbox">
                @Html.EditorFor(model => model.ReservedRoute)
                @Html.ValidationMessageFor(model => model.ReservedRoute, "", new { @class = "text-danger" })
            </div>
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ReservedBy, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ReservedBy, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ReservedBy, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ReservedDate, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ReservedDate, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ReservedDate, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.CP_WorkCompleted, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <div class="checkbox">
                @Html.EditorFor(model => model.CP_WorkCompleted)
                @Html.ValidationMessageFor(model => model.CP_WorkCompleted, "", new { @class = "text-danger" })
            </div>
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Work_Comments, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Work_Comments, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Work_Comments, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.CP_ProjectNo, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.CP_ProjectNo, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.CP_ProjectNo, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ReservedCat, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ReservedCat, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ReservedCat, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
</div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

Statewide Model

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Roadway_History.Models
{
    using System;
    using System.Collections.Generic;
    
    public partial class Statewide
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public Statewide()
        {
            this.Documents1 = new HashSet<Document>();
        }
    
        public int ID { get; set; }
        public string COUNTY { get; set; }
        public string SignSys { get; set; }
        public string RouteNoOrigImport { get; set; }
        public Nullable<int> RouteNo { get; set; }
        public Nullable<int> SuppDes { get; set; }
        public string LocalName { get; set; }
        public Nullable<System.DateTime> DateNumber { get; set; }
        public string Method { get; set; }
        public string OriginalL { get; set; }
        public string OriginalD { get; set; }
        public string Projects { get; set; }
        public string Documents { get; set; }
        public string Comments { get; set; }
        public Nullable<int> District { get; set; }
        public bool Duplicate_OK { get; set; }
        public string RightofWay { get; set; }
        public bool ReservedRoute { get; set; }
        public string ReservedBy { get; set; }
        public Nullable<System.DateTime> ReservedDate { get; set; }
        public bool CP_WorkCompleted { get; set; }
        public string Work_Comments { get; set; }
        public string CP_ProjectNo { get; set; }
        public Nullable<int> ReservedCat { get; set; }
        public string Add_User { get; set; }
        public Nullable<System.DateTime> Date_Added { get; set; }
    
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<Document> Documents1 { get; set; }
    }
}

And here is the database table:

enter image description here

And here is a quick example of some data that works fine if I add it to the database directly through the Management Studio but does not work in the application

enter image description here

Cole Perry
  • 197
  • 21
  • Check if the ex (Exception) objects have their innerException property filled, if so, extra error info can be found there. – Etienne Jul 08 '21 at 18:28
  • How do I check for that? Usually if I get this error a window pops up in VS and I can dig down to see what the problem was. This is not happening on the server. – Cole Perry Jul 08 '21 at 18:31
  • in the catch area of your code, you add something like this: if ex.InnerException !- null then Response.Write ex.InnerException.Message – Etienne Jul 08 '21 at 18:35
  • @Etienne I edited the question to show that I tried this but there were no changes. Same error messages and same thing happened. – Cole Perry Jul 08 '21 at 18:48
  • Well, there is very likely something wrong with the data you are trying to save (DbEntityValidationException), and propably a mandatory table field you did not fill (NullReferenceException). – Etienne Jul 08 '21 at 18:50
  • @Etienne Those NullReferenceExceptions happen before I try to submit anything. They happen when the Create page loads. There are no fields to be null at this time. – Cole Perry Jul 08 '21 at 18:52
  • well, the program is trying to load something from the database (DbEntityValidationException in EntityFramework.dll), so you might look in to that. Maybe use SQL Profiler to see what the program is trying to do on the database... – Etienne Jul 08 '21 at 18:55
  • Can you post your view pls? – Serge Jul 08 '21 at 19:01
  • @Serge I added it to the bottom. – Cole Perry Jul 08 '21 at 19:04
  • Thanks, and please post Statewide model class too – Serge Jul 08 '21 at 19:18
  • @Serge added it at the bottom as well. Thank you. – Cole Perry Jul 08 '21 at 19:20
  • Have you tried to view EntityValidationErrors while debugging? https://stackoverflow.com/questions/7795300/validation-failed-for-one-or-more-entities-see-entityvalidationerrors-propert/22638624#comment102704769_22638624 – Chris Wong Jul 09 '21 at 04:43
  • @ChrisWong I would love to do that, however this option does not come up in Visual Studio. It only appears in the console and I don't know how to get there without that error popup happening like in the link you shared. – Cole Perry Jul 12 '21 at 12:52

1 Answers1

1

try this

   public ActionResult Create()
        {
            var model= new Statewide();
            return View(model);
        }

and try to remove [Bind] from POST action, you don't need it since you are binding all properties any way

public ActionResult Create( Statewide statewide)

and try to add a hidden ID field too

@Html.HiddenFor(m => m.ID)
Serge
  • 40,935
  • 4
  • 18
  • 45
  • So that did solve the errors that occured as the page loaded so thank you. But it does not fix the error of the records not saving to the database. How can I get more info in Visual Studios about those errors? – Cole Perry Jul 08 '21 at 19:32
  • @ColePerry You will have to post some of your db context. I don't see any data anotation in your Statewide class. If you use fluent apis pls post them for Statewide. It would be nice to see what properties are required and should not be null or 0. What about Id - is it autoincrementing? – Serge Jul 08 '21 at 19:48
  • What do you mean by db context exactly? What file is this referring to and I'll gladly share. Yes, ID is auto incrementing. – Cole Perry Jul 08 '21 at 19:54
  • I added a pic of the database table if that is what you mean. – Cole Perry Jul 08 '21 at 19:55
  • I also added a pic of an example of data that should work. – Cole Perry Jul 08 '21 at 20:00
  • What about ID key, does DB creates it? – Serge Jul 08 '21 at 20:02
  • Yes. The database creates an Auto Incrementing ID for every entry. – Cole Perry Jul 08 '21 at 20:04
  • Serge do you have any other ideas? I'm still trying to figure this out. – Cole Perry Jul 12 '21 at 17:01
  • Try to replace var userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; with var userName="John"; and DateTime.Today() with DateTime.Now; – Serge Jul 12 '21 at 17:15
  • Serge bless you're heart you code god you. The server did not like how I was getting the username. That was the problem. Thank you so so much. I will fix that now. Again, thank you! – Cole Perry Jul 12 '21 at 18:08