-2

我在执行以下代码时遇到问题(语法错误)。请帮助我该怎么办。谢谢。

表列:pId, pAltId, pMobile, pDate, pName

变量:argID, alt_ID, p_mobile, p_date, p_Name

陈述:

String selectStr = "select * from " + thisTable + " where pId = '" + argID "+  OR  + 
pAltId = " + alt_ID "+ OR + pMobile =" + p_mobile "+ OR +  pDate =" + p_date "+ OR + 
pName = "+ p_Name "'";
4

1 回答 1

1

pId+ " where pId = '" + argID "+的值是否应该用单引号括起来?你有一个开始',但没有结束。

此外,您似乎缺少许多双引号或将它们放在错误的位置,缺少许多空格,并且缺少 pName 的起始 '。尝试:

String selectStr = "select * from " + thisTable + " where pId = " + argID + " " 
    + OR + " pAltId = " + alt_ID + " " + OR + " pMobile = " + p_mobile + " " 
    + OR + " pDate = '" + p_date + "' " + OR + " pName = '" + p_Name + "'";

如果 pMobile 是一个字符串,那么您将需要更改+ " pMobile = " + p_mobile + " "+ " pMobile = '" + p_mobile + "' "

于 2013-03-26T22:46:10.923 回答