偶今天用 ADOCommand.CommandText := 'SELECT * FROM :table',然后设置 Peremeter,却“SELECT语法错误”,后来改为字符串拼接,一切正常。然后又尝试“INSERT .... VALUES(:peremeter)”、“INSERT INTO :peremater ....”,均无法成功,唯一只有 “WHERE=:peremeter” 能成功。特上来问一下各位高手,Peremeter 是不是只能用在 WHERE 的内容?
调试欢乐多
CommandText := 'INSERT INTO Talley ' +
'(Counter) ' +
'VALUES (:NewValueParam)';
CommandType := cmdText;
Parameters.ParamByName('NewValueParam').Value := 57;
Execute
end;
with ADOCommand1 do begin
CommandText := 'INSERT INTO :table ' +
'(Counter) ' +
'VALUES (:NewValueParam)';
CommandType := cmdText;
Parameters.ParamByName('NewValueParam').Value := 'Talley';
Parameters.ParamByName('NewValueParam').Value := 57;
Execute
end;这样就执行不了!
CommandText := 'INSERT INTO :table ' +
'(Counter) ' +
'VALUES (:NewValueParam)';
CommandType := cmdText;
Parameters.ParamByName('table').DataType := ftString;
Parameters.ParamByName('table').Value := 'Talley';
Parameters.ParamByName('NewValueParam').Value := 57;
Execute
end;
cmd: string ='select * from %s';
begin
...
adoCommand.CommandText := Format(cmd, [tablename]);
...
end;