如何在ASP中修改此UPDATE命令? [英] How to Slove This UPDATE command in asp?
本文介绍了如何在ASP中修改此UPDATE命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string str = "UPDATE EMPDETAILS SET NAME=@name,DEPT=@dept,CITY=@city WHERE chkstatus=@chkstatus AND EMPID=empid";
cmd = new SqlCommand(str, con);
cmd.Parameters.AddWithValue("@empid", txtempid.Text);
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@dept", txtdept.Text);
cmd.Parameters.AddWithValue("@city", txtcity.Text);
cmd.Parameters.AddWithValue("@chkstatus", status.Trim());
cmd.ExecuteNonQuery();
GridView1.DataBind();
lblmsg.Text = "RECORD UPDATE SUCCESSFULLY";
con.Close();
btnsubmit.Visible = false;
btnupd.Visible = true;
txtempid.ReadOnly = true;
Binddata()
推荐答案
但是,我在您的代码中看到一个简单的故障,因此将其放在此处的解决方案框中.更新语句中的"empid"未通过"@"符号进行参数设置
However, I can see one simple glitch in your code and so I m putting it in the solution box here. The "empid" in your update statement is not parameterised by the "@" symbol
string str = "UPDATE EMPDETAILS SET NAME=@name,DEPT=@dept,CITY=@city WHERE chkstatus=@chkstatus AND EMPID=@empid";
我不确定这是否是您想要的,但这至少是我在您的代码中发现的一个问题.对于其他任何事情,您都必须告诉我们.
I am not sure if this is what you wanted but this is atleast one problem that i spotted in your code. For anything else you''ve got to tell us so.
在主字符串中的empid
中添加一个"@"字符:
Add an ''@'' character toempid
in the main string:
string str = "UPDATE EMPDETAILS SET NAME=@name,DEPT=@dept,CITY=@city WHERE chkstatus=@chkstatus AND EMPID=empid";
成为
string str = "UPDATE EMPDETAILS SET NAME=@name,DEPT=@dept,CITY=@city WHERE chkstatus=@chkstatus AND EMPID=@empid";
这样就可以匹配参数名称
That way it matches the paramater name
这篇关于如何在ASP中修改此UPDATE命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文