Classs a
[the Display (Name="Name")]
Public string name {get; set; }
[the Display (Name="gonghaowu")]
Public string id_card {get; set; }
[Required (ErrorMessage="please enter the asset number")]
[the Display (Name="asset number")]
Public string pc_code {get; set; }
[the Display (Name="creation time")]
Public DateTime? Create_time {get; set; }
Added [Required (ErrorMessage="please enter the asset number")] this line
The repository data that was read out, if free this field will be an error inside the
I need now is, write new in this field cannot be empty of
Free, but before a repository can be normal read
An unhandled exception occurred while processing the request.
SqlNullValueException: Data is Null. This method or property always be called on Null values.
Microsoft. The Data. SqlClient. SqlBuffer. ThrowIfNull ()
CodePudding user response:
Two roadsEither the database with the update statement of Null values to an empty string, such as update TableName set ColName='where ColName is Null
Or is the judgment when you read from the database system. Dbnull. Value, is replaced with an empty string
CodePudding user response:
"The data repository read" how to write?DBNull database value read from the ado.net need to decide, for example,
if (value=https://bbs.csdn.net/topics/=DBNull. Value)
Xd=string. The Empty;
The else
Xd=(string) res;
CodePudding user response:
The