java.sql.SQLException: [Microsoft][SQL Native Client][SQL Server]关键字 'and' 附近有语法错误。 at
java.sql.SQLException:[Microsoft][SQLNativeClient][SQLServer]关键字'and'附近有语法错误。atsun.jd...
java.sql.SQLException: [Microsoft][SQL Native Client][SQL Server]关键字 'and' 附近有语法错误。
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253) 展开
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253) 展开
3个回答
展开全部
上sql语句啊···
追问
sql语句是这样的
String sql = "select PurchaseID,ProductsType,ProductsID, PurchaseDate from PurchaseDetail";
if (pd.getPurchaseID() != null && !pd.getPurchaseID().equals("")) {
sql = sql + " and PurchaseID like '%" + pd.getPurchaseID() + "%'";
}
}
追答
select PurchaseID,ProductsType,ProductsID, PurchaseDate from PurchaseDetail and PurchaseID like '%" + pd.getPurchaseID() + "%'"这是sql语句么?
把and换成where
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-05-06
展开全部
报错的那个地方的SQL语句呢
贴出来看看
贴出来看看
追问
String sql = "select PurchaseID,ProductsType,ProductsID, PurchaseDate from PurchaseDetail";
if (pd.getPurchaseID() != null && !pd.getPurchaseID().equals("")) {
sql = sql + " and PurchaseID like '%" + pd.getPurchaseID() + "%'";
}
这里用and了 }
追答
select PurchaseID,ProductsType,ProductsID, PurchaseDate from PurchaseDetail
改成
select PurchaseID,ProductsType,ProductsID, PurchaseDate from PurchaseDetail where 1=1
这样就可以在后面随意拼接SQL了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询