無法將值NULL插入'描述...'列無法將值NULL插入'描述
任何人都可以幫助我嗎?請高度讚賞.. 這裏是我的小巧代碼插入說明,數量,成本和HSCode,只有說明Colume不工作,說插入價值NULL列'說明。
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();
}
看起來你'Description'列不允許空和你實際提供這樣的價值在incomingShipmentLine的'Description'屬性中。要麼你應該正確填充對象,不要使用非空值,要麼應該將值重寫爲某個空字符串,否則應該將列更改爲接受空值。 –
非常感謝你 - Jakub Szumiato,它的工作...... :) - Namaraj Giri –