简体   繁体   中英

Error Data is Null in Asp.net core using stored procedure

Hi I am trying to get data from my stored procedures

Here's my Controller DashboardController

Here's my ViewModel DashboardViewModel

Here's my Javascript AJAXPhoto1 AJAXPhoto2

Here's my table table

getting an error of SqlNullValueException: Data is Null. This method or property cannot be called on Null values

Note: my stored procedure is displaying values when executed from sql only not in the asp.net core

im still new to asp.net core and first time using stored procedure without entity framework. Any help is appreciated. Thank you!

Your problem should be caused by the existence of a null value in the table in the database.

The DateTime type in your ViewModel does not allow null values, it's [Required] by default. However, since the attribute may have a null value in your database, so you need to change your DateTime type to nullable type like following.

 public DateTime? DateStarted{ get; set; }
 public DateTime? DateCompleted{ get; set; }
 public DateTime? DueDate{ get; set; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM