AM試圖更新該查詢中的日期我在UPDATE語句收到此錯誤語法錯誤,這是我的代碼查詢表達式中的語法錯誤(缺少運算符)'05 -04-2014 AM 12:00:00'C#?
Updated Code
OleDbCommand top = new OleDbCommand(
"UPDATE NewInvoice_1 SET (" +
"Terms=?, [InvoiceDate]=?, OurQuote=?," +
"SalesPerson=?, CustomerName=?, OrderNumber=?," +
"InvoiceAddress=?, DeliveryAddress=?," +
"WholeDiscountP=?, WholeDiscountA=?, ShippingP=?, ShippingA=?," +
"Price=?, Discount=?, Tax=?," +
"Shipping=?, GrandTotal=?, TaxforDisc=?, DiscountType=?," +
"ShippingBy=?, ShipReferenceNo=?, IsInsured=?, Notes=?," +
"[DueDate]=?, AmountinWords=?) WHERE InvoiceId=?", conn);
top.Parameters.AddWithValue("?", CBL_Terms.EditValue.ToString());
top.Parameters.AddWithValue("?", CBL_Date.DateTime);
top.Parameters.AddWithValue("?", TXE_OurQuote.Text);
top.Parameters.AddWithValue("?", CBL_Sales_Person.EditValue.ToString());
top.Parameters.AddWithValue("?", CBL_Customer_Name.EditValue.ToString());
top.Parameters.AddWithValue("?", TXE_Order_Number.Text);
top.Parameters.AddWithValue("?", TXE_Invoice_Address.Text);
top.Parameters.AddWithValue("?", TXE_Delivery_Address.Text);
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_FlatDiscountP.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_FlatDiscountA.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_ShippingPercentage.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_ShippingAmount.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_SubTotal.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_Discount.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_Tax.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_Shipping.Text));
top.Parameters.AddWithValue("?", Convert.ToDecimal(TXE_GrandTotal.Text));
top.Parameters.AddWithValue("?", barCheckItem1.Checked);
top.Parameters.AddWithValue("?", selectedItem);
top.Parameters.AddWithValue("?", TXE_Shipping_By.Text);
top.Parameters.AddWithValue("?", TXE_Reference_No.Text);
top.Parameters.AddWithValue("?", CBX_Is_Insured.Checked);
top.Parameters.AddWithValue("?", TXE_Notes.Text);
top.Parameters.AddWithValue("?", CBL_DueDate.DateTime);
top.Parameters.AddWithValue("?", TXE_AmountinWords.Text);
top.Parameters.AddWithValue("?", TXE_Unvisible.Text);
top.ExecuteNonQuery();
現在更新我的代碼參數,但是在得到語法錯誤更新代碼
爲什麼不使用參數化查詢? –
認真,你在做這個嗎? –
文本和日期時間值必須是用引號括起來的字符串文字。但嚴重的是,不要這樣做。使用參數化查詢。 [這使您可以開放SQL注入](http://xkcd.com/327/) –