gpt4 book ai didi

c# - 将文本框值更新为 sql

转载 作者:行者123 更新时间:2023-11-30 19:49:50 24 4
gpt4 key购买 nike

当我尝试将文本框值更新到 db 中时,它抛出一个异常“附近的无效语法(txtkey.text 的值)”任何人都可以帮助

SqlConnection con = new SqlConnection("server=server1;Database=testdb;User Id=dev;password=sqlad@2006");
SqlCommand com = new SqlCommand("insert into tbl_licensing(UserName,CompanyName,EmailId,LicenseKey) values ('" + txtUserName.Text + "','" + txtCompanyName.Text + "','" + txtEmailId.Text + "','"+ txtKey.Text + "'",con);
con.Open();
com.ExecuteNonQuery();
con.Close();

最佳答案

您已启动此“values ()”但您从未关闭它。请再次检查。

如果不直接写查询,用参数化查询或者存储过程就好了

你可以查看这篇文章。

http://www.aspnet101.com/2007/03/parameterized-queries-in-asp-net/

关于c# - 将文本框值更新为 sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3343288/

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