Topic: [Jsp]SQL语句问题

  Print this page

1.[Jsp]SQL语句问题 Copy to clipboard
Posted by: ggloverv
Posted on: 2008-12-20 23:36

JSP2.0里

int id = Integer.parseInt(request.getParameter("id"));
String sql = "select * from [news] where nID="+id; //报错
ResultSet rs = conn.executeQuery(sql);

因为SQLserver里 nID那个字段是int型自动增1的。
请问红色那语句该怎么写。或有什么其他思路呢?

2.Re:[Jsp]SQL语句问题 [Re: ggloverv] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-12-26 23:51

select * from news where nID=" +id

That is no sqaure brackets [].

Regards,
Jiafan


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923