showMessage(sql)下看看sql:='select field1 from table1 where '+s; 有可能where后边要加个空格
字符串连在一起了,运行时SQL的值='select field1 from table1 whereid>7'。要在where后面加一个空格字符,就会变成:'select field1 from table1 where id>7',其实2楼说得很明白啦,自己调试下嘛
sql:='select field1 from table1 where'+s 这样写不太好吧 改成这样试一试: sql:='select field1 from table1'; if (条件) then sql:=sql+'where id>7'; if (条件) then sql:=sql+'where id<7'; if (条件) then sql:=sql+'where id=7';新手回答问题,见笑了!
showMessage(sql)下看看要不把错误贴上来!
可能是空格的原因,改成 sql:='select field1 from table1 where '+s 最好养成习惯,在字符相加前,都预留下空格。 楼主最好把错误提示也贴出来,更容易判断错误原因。
有可能where后边要加个空格
这样写不太好吧
改成这样试一试:
sql:='select field1 from table1';
if (条件) then
sql:=sql+'where id>7';
if (条件) then
sql:=sql+'where id<7';
if (条件) then
sql:=sql+'where id=7';新手回答问题,见笑了!
sql:='select field1 from table1 where '+s
最好养成习惯,在字符相加前,都预留下空格。
楼主最好把错误提示也贴出来,更容易判断错误原因。