我在字符串''之後得到未封閉的引號。我已經嘗試了一切幫助將不勝感激。C#Sql服務器更新與多個where子句和多個id字段
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sipConnectionString"].ConnectionString);
protected void Button1_Click(object sender, EventArgs e)
{
conn.Open();
string query = "select dealercode, dropdate, couponno from coupon where dealercode = '" + DEALERCODETextBox.Text + "' and dropdate = '" + DROPDATETextBox.Text + "' and COUPONNO = '" + COUPONCOUNTTextBox.Text +"','";
SqlCommand cm = new SqlCommand(query, conn);
cm.Parameters.AddWithValue("@couponcount", COUPONCOUNTTextBox.Text);
cm.Parameters.AddWithValue("@totalrev", GRANDTOTALTextBox.Text);
cm.ExecuteNonQuery();
conn.Close();
感謝您的答覆我修改了代碼,你的建議我的錯誤已被清除,但是當我點擊提交按鈕的所有文本框填寫表單永遠不會將任何信息添加到數據庫有沒有辦法找到什麼不是當點擊提交按鈕時發生的事情 –