注册 登录
编程论坛 ASP.NET技术论坛

[求助]asp.net中更新不了是怎么回事?

elite88 发布于 2007-08-29 14:30, 492 次点击

大家帮我看看,这是怎么回事,
string id = e.Item.Cells[0].Text;//非编辑状况
string username=((TextBox)(e.Item.Cells[1].Controls[0])).Text;
string cardid = ((TextBox)(e.Item.Cells[2].Controls[0])).Text;
string workername = ((TextBox)(e.Item.Cells[3].Controls[0])).Text;
string sex=((TextBox)(e.Item.Cells[4].Controls[0])).Text;
string huji = ((TextBox)(e.Item.Cells[5].Controls[0])).Text;
string birthdate=((TextBox)(e.Item.Cells[6].Controls[0])).Text;
string duty=((TextBox)(e.Item.Cells[7].Controls[0])).Text;
string comdate=((TextBox)(e.Item.Cells[8].Controls[0])).Text;
SqlConnection con = db.createconnection();
con.Open();
SqlCommand cmd = new SqlCommand( "update worker set username='" + username + "',cardid='"+cardid+"',workername='" + workername + "',sex='" + sex + "',huji='" + huji + "',birdate='" + birthdate + "',duty='" + duty + "',comdate='" + comdate + "' where id='"+id+"'",con);
cmd.ExecuteNonQuery();
为什么这个语句更新运行没有错误,却没有效..

4 回复
#2
yunj11052007-08-29 14:35
你的page_load里有加!ispostback吗?
#3
梦灵儿2007-08-29 19:20
不需要加吧。。。。。感觉写的有问题。
string sqlstr="update worker set username='" + username + "',cardid='"+cardid+"',workername='" + workername + "',sex='" + sex + "',huji='" + huji + "',birdate='" + birthdate + "',duty='" + duty + "',comdate='" + comdate + "' where id="+id;
SqlCommand cmd = new SqlCommand(sqlstr,con);
这样。试哈.......

#4
师妃暄2007-08-30 14:20
SqlCommand cmd = new SqlCommand( "update worker set username='" + username + "',cardid='"+cardid+"',workername='" + workername + "',sex='" + sex + "',huji='" + huji + "',birdate='" + birthdate + "',duty='" + duty + "',comdate='" + comdate + "' where id='"+id+"'",con);


我的天..现在还有人这么写
#5
zw3798688722007-09-03 16:16
请问你的id是什么类型的哦,检查哈语句
——周伟
——邮箱:zw_asp.net@163.com
——QQ:379868872
1