主题:我在adoquery中写入查询语句,编译却不能通过
sql.Clear;
sql.Add('declare @tablename varchar(20) declare @field varchar(20) declare @str varchar(600) ');
sql.Add('set @tablename=''''basicInfo'''' set @field=''''zy'''' set @str=''''select distinct ''''+@field+'''' from ''''+@tablename+''' ');
sql.add('exec(@str) ');
我在adoquery中写入查询语句,编译却不能通过,
Build
[Error] FunctionBase.pas(52): Missing operator or semicolon
[Error] FunctionBase.pas(52): ')' expected but identifier 'exec' found
[Error] FunctionBase.pas(52): Unterminated string
[Error] FunctionBase.pas(53): Missing operator or semicolon
[Error] FunctionBase.pas(57): Variable required
[Fatal Error] Student_info2.dpr(10): Could not compile used unit 'FunctionBase.pas'
大家帮我找一下啊,谢谢
这个语句的目的是 查询 返回 某表中某列的值
sql.Add('declare @tablename varchar(20) declare @field varchar(20) declare @str varchar(600) ');
sql.Add('set @tablename=''''basicInfo'''' set @field=''''zy'''' set @str=''''select distinct ''''+@field+'''' from ''''+@tablename+''' ');
sql.add('exec(@str) ');
我在adoquery中写入查询语句,编译却不能通过,
Build
[Error] FunctionBase.pas(52): Missing operator or semicolon
[Error] FunctionBase.pas(52): ')' expected but identifier 'exec' found
[Error] FunctionBase.pas(52): Unterminated string
[Error] FunctionBase.pas(53): Missing operator or semicolon
[Error] FunctionBase.pas(57): Variable required
[Fatal Error] Student_info2.dpr(10): Could not compile used unit 'FunctionBase.pas'
大家帮我找一下啊,谢谢
这个语句的目的是 查询 返回 某表中某列的值