日期:2014-05-19  浏览次数:20746 次

jsp 大神指教
public boolean modify_user_info()
{
this.date=new Date().toLocaleString();
this.strsql="update user_info set ";
this.strsql=this.strsql+"sex="+"''"+this.sex+"',";
this.strsql=this.strsql+"sign="+"''"+this.sign+"',";
this.strsql=this.strsql+"email="+"''"+this.email+"',";
this.strsql=this.strsql+"date="+"'"+this.date+"'";
this.strsql=this.strsql+"where use_id=' "+this.user_id+"'";
boolean isUpdate=super.update(this.strsql);
return isUpdate;
}
public boolean modify_password( )
{
this.strsql="update user_info set";
this.strsql=this.strsql+"password='"+this.password+"'";
this.strsql=this.strsql+"where user_id="+this.user_id;
boolean upsd=super.update(this.strsql);
return upsd;
}
麻烦各位给看看这两段代码哪里错了,老写不进数据库啊!!

------解决方案--------------------
你能不能用stringBuffer的说
------解决方案--------------------
不进数据库?
 你断点 得到完整语句 测试看哪里出错不就知道了吗?
------解决方案--------------------
this.strsql=this.strsql+"sex="+"''"+this.sex+"',";
为什么不改成
this.strsql=this.strsql+"sex='"+this.sex+"',";
再者,实在想传Sql语句的话建议用StringBuffer追加,不然,你可以用占位符,那样多直观
------解决方案--------------------
如果strsql是string类型
可以用
this.strsql+="update user_info set ";
http://www.zhjie.net
------解决方案--------------------
检查一下,strsql语句有点问题
------解决方案--------------------
sql语句拼错了,建议用StringBuffer或StringBuilder。
------解决方案--------------------
貌似你拼接的sql,有些地方没有加空格啊,成了
update user_info set set password=‘password’where 这里貌似没有空格。
建议每行拼接的开头和结尾都加上空格(变量的拼接应在单引号后面加)。
还有,这种方式入土都很多年了,还是从ssh看起吧。
------解决方案--------------------
打印一下strsql,看语句格式及语法是否有误。