当前位置: 代码迷 >> Java Web开发 >> [求助] UPDATE语句中涉及字符串对象时如何写?
  详细解决方案

[求助] UPDATE语句中涉及字符串对象时如何写?

热度:533   发布时间:2004-12-15 16:31:00.0
[求助] UPDATE语句中涉及字符串对象时如何写?

我是用 String id=new String(request.getParameter("id")); String title=new String(request.getParameter("title")); String content=new String(request.getParameter("content"));

String strSQL="update news set newstitle=“+ title + ”,set newscontent="+ content +“'where id=“+id;

更新数据库中数据时用news.executeUpdate(strSQL)

//news是自己编写的一个javaBean

报错::连接数据库失败了,异常为:[Microsoft][ODBC Microsoft Access Driver] UPDATE 语句的语法错误。

请问是怎么回事?

String strSQL="update news set newstitle='dfjeo',newscontent='jsdfow' where id="+id;这样时没问题的。

搜索更多相关主题的帖子: String  UPDATE  语句  数据库  

----------------解决方案--------------------------------------------------------

问题解决了,是我自己太粗心了。

竟然写了两个set。还有改为:

String strSQL="update news set newstitle='" + title + "', newscontent='"+ content +"'where id="+id;


----------------解决方案--------------------------------------------------------
  相关解决方案