gpt4 book ai didi

具有多个 where 子句和多个 id 字段的 C# Sql Server 更新

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:12 25 4
gpt4 key购买 nike

我在字符串 '' 后得到未闭合的引号。我已经尝试了所有方法,如有任何帮助,我们将不胜感激。

        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();

最佳答案

在你的查询字符串的最后

and COUPONNO = '" + COUPONCOUNTTextBox.Text +"','";

+"','"; 替换为 "'";

注意:您的查询字符串还缺少Parameters

关于具有多个 where 子句和多个 id 字段的 C# Sql Server 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31334349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com