我是離子1.我已經在瀏覽器中測試了我的應用程序,它工作正常。我用過sqlite。我有一個表格。當我將一個文本輸入字段留空時,數據被添加到數據庫表中。這正是我想要的。但是,它不適用於設備。每當我離開一個字段爲空它顯示了以下錯誤:sqlite3_step失敗:NOT NULL約束失敗
Object {message: "sqlite3_step failure: NOT NULL constraint failed: items.barcode", code: 6}
這裏是我的代碼片段:
if ($scope.item.itemname && $scope.item.soldby && $scope.item.price) {
var query = "INSERT into items (itemname,category,soldby,price,sku,barcode) VALUES(?,?,?,?,?,?)";
$cordovaSQLite.execute(db, query, [$scope.item.itemname, $scope.item.category, $scope.item.soldby, $scope.item.price, $scope.item.sku, $scope.item.barcode,])
.then(function (result) {
console.log($scope.item.itemname);
console.log($scope.item.category);
console.log($scope.item.soldby);
console.log($scope.item.price);
console.log($scope.item.sku);
console.log("Printing barcode");
console.log($scope.item.barcode);
console.log($scope.item.total);
//ITEM ADDED SUCCESS POPUP STARTS
//ITEM ADDED SUCCESS POPUP ENDS
}, function (error) {
console.log(error);
});
// $scope.item = {
// itemname: $scope.item.itemname,
// };
$state.go('menu.allItems');
}
這裏是我創建表的代碼:
您是否曾在「條形碼」列上使用NOT NULL約束表的以前版本? –
是的,我確實有。 –
那怎麼辦? @CL。 –