Cannot insert the value NULL into column 'Description...
Can anyone help me ? Please , It will be highly appreciated.. Here is my Dapper Code to insert the Description, Quantity, Cost and HSCode and only the Description Colume is not working saying insert the value NULL into column 'Description.
public void CreateIncomingShipmentLine(IncomingShipmentLine incomingShipmentLine)
{
DbConnection _Connection = new SqlConnection(Constant.DatabaseConnection);
_Connection.Open();
// IncomingShipmentLine
string myIncomingShipmentLineQuery = "INSERT INTO IncomingShipmentLine( Description, Quantity, Cost, HSCode) VALUES ( @Description, @Quantity, @Cost, @HSCode)";
_Connection.Execute(myIncomingShipmentLineQuery, new
{
Description = incomingShipmentLine.Description,
Quantity = incomingShipmentLine.Quantity,
Cost = incomingShipmentLine.Cost,
HSCode = incomingShipmentLine.HSCode
});
_Connection.Close();
}
Descriptioncolumn doesn't allow nulls and you actually provide such value in theDescriptionproperty of theincomingShipmentLine. Either you should populate the object properly wth not-null value, or you should override the value to some empty string, or you should change your column to accept nulls.