更新数据库的语句
<%
String id=trans(request.getParameter( "id "));
String name=trans(request.getParameter( "name "));
Float price=(float)(request.getParameter( "price "));
String producer=trans(request.getParameter( "producer "));
String descript=trans(request.getParameter( "descript "));
String type=trans(request.getParameter( "type "));
Connection conn=db.getConnection();
Statement stmt=conn.createStatement();
String sql= "update products set productid= ' "+id+ " ',category= " ' "+type+ " ',name= ' "+name+ ",producer= ' "+producer+ " ',price= ' "+price+ " ',descn= ' "+descript+ " ' where productid= ' "+id+ " ' ";
stmt.executeUpdate(sql);
%>
请问更新数据库的语句应该怎么写
就是我上面的SQL语句写错了
请问具体应该怎么写
数据库中的字段是:productid,category,name,producer,price,descn
要讲原数据库中的数据修改为:上面用RS得到的数值
我所写的SQL语句对应是正确的
就是引号或者语法什么的有错误
请大家帮忙修改
谢谢
------解决方案--------------------category= " '多一个”,+name+ ",少一个’,
------解决方案--------------------String sql= "update products set productid= ' "+id+ " ', "+category+ "= 'type ', "+name+ "= 'name ', "+producer+ "= 'producer ', "+price+ " 'price ', "+descn+ " 'descript ' where "+productid+ "= ' "+id+ " ' ";
------解决方案--------------------stmt.executeUpdate(sql);
前面加一句out.println(sql)把sql打印出来看看
------解决方案--------------------String sql= "update products set productid= ' "+id+ " ',category= ' "+type+ " ',name= ' "+name+ ",producer= ' "+producer+ " ',price= ' "+price+ " ',descn= ' "+descript+ " ' where productid= ' "+id+ " ' ";