$variable = array("apple" , "orange" , null, "apple2"); DB::statement("UPDATE table1 SET field1= IsNull($variable[0],field1), field2= IsNull($variable[2],field2), where = someconditional")
我想如果数据数组中的字段为空则不更新但仅更新该字段。其他字段(如果不为null)进行更新 如何在laravel中编写此代码?
答案 0 :(得分:0)
试试这个
string str = "";
str = listBox2.SelectedItem.ToString();
if (listBox2.Items.Count == 0)
{
MessageBox.Show("Production Completed");
string clb = "";
if (checkedListBox.Items.Count <= 0)
{
for (int i = 0; i < checkedListBox.Items.Count; i++)
{
if (str == "")
{
str = checkedListBox.Items[i].ToString();
}
}
MAcon.Open();
OleDbCommand cmd = new OleDbCommand("Insert into Inventory([Product ID], [Order ID], Barcode, SubBarcode, [Completion Date]) values(@ProductID, @OrderID, @Barcode, @SubBarcode, @CompletionDate)", MAcon);
cmd.Parameters.AddWithValue("@ProductID", ProductID.Text);
cmd.Parameters.AddWithValue("@OrderID", OrderID.Text);
cmd.Parameters.AddWithValue("@Barcode", BarcodeTxt.Text);
cmd.Parameters.AddWithValue("@CompletionDate", Date.Text);
cmd.Parameters.AddWithValue("@SubBarcode", clb);
cmd.ExecuteNonQuery();
DialogResult start = MessageBox.Show("Production has begun", "Warning", MessageBoxButtons.OK);
MAcon.Close();
}
}