我的更新命令代码:
public void update(name,email,phone)
{
using {sqlconnection con=new sqlconnection("some connection source"))
{
con.open();
string str = "UPDATE register SET name = @name,email = @email WHERE phone = "@phone";
using(sqlcommand cmd=new sqlcommand(str,con))
{
cmd.commandtype=commandtype.text;
cmd.parameters.addwithvalue("@name",name);
cmd.parameters.addwithvalue("@email",email);
cmd.parameters.addwithvalue("@phone",phone);
cmd.executenonquery();
}
}
}
我的行更新事件是这样的:
string name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
string email = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
int phone = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[3].Text);
update(name, email, phone);
GridView1.EditIndex = -1;
bindgridview();
在我的桌面电话中,主键是主键,当我按下更新按钮时,它不会触发没有任何变化。谁能看到我的代码并告诉我哪里做错了