var
Form1: TForm1;
sqr: string;
implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject);
sqr:='CREATE TABLE #oigl (guig char(10),shl char(10),intime datetime,bz char(50))';
sqr:=sqr+''+'insert into #oigl select guig,shl,intime,bz from gpinlog union';
sqr:=sqr+'select guig,shl,s_intime,bz from czgl_i union';
sqr:=sqr+'select guig,shl,wctime,bz from gdb';
sqr:=sqr+''+'select guig as'+''规格','+'shl as'+''数量','+'intime as'+''进库时间','+'bz as'+''备''';
sqr:=sqr+''+'from #oigl';
begin
with ADOQuery1 do
begin
close();
sql.clear();
sql.add(sqr);
execsql;
end;
end;错误提示:
[Error] Unit1.pas(33): Unknown directive: 'sqr'
[Error] Unit1.pas(34): Illegal character in input file: '规' ($B9E6)
[Error] Unit1.pas(34): Illegal character in input file: '数' ($CAFD)
[Error] Unit1.pas(34): Illegal character in input file: '进' ($BDF8)
[Error] Unit1.pas(34): Illegal character in input file: '备' ($B1B8)
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
Form1: TForm1;
sqr: string;
implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject);
sqr:='CREATE TABLE #oigl (guig char(10),shl char(10),intime datetime,bz char(50))';
sqr:=sqr+''+'insert into #oigl select guig,shl,intime,bz from gpinlog union';
sqr:=sqr+'select guig,shl,s_intime,bz from czgl_i union';
sqr:=sqr+'select guig,shl,wctime,bz from gdb';
sqr:=sqr+''+'select guig as'+''规格','+'shl as'+''数量','+'intime as'+''进库时间','+'bz as'+''备''';
sqr:=sqr+''+'from #oigl';
begin
with ADOQuery1 do
begin
close();
sql.clear();
sql.add(sqr);
execsql;
end;
end;错误提示:
[Error] Unit1.pas(33): Unknown directive: 'sqr'
[Error] Unit1.pas(34): Illegal character in input file: '规' ($B9E6)
[Error] Unit1.pas(34): Illegal character in input file: '数' ($CAFD)
[Error] Unit1.pas(34): Illegal character in input file: '进' ($BDF8)
[Error] Unit1.pas(34): Illegal character in input file: '备' ($B1B8)
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
2)sqr没有声明。
procedure TForm1.FormShow(Sender: TObject);
var
sqr: string;
begin
//...
end; 3) 引号少了,delphi中要在字符串中加一个单引号,必须用两个:''.
sqr:=sqr + ''+ 'select guig as'+'''规格''',+'shl as'+'''数量''','+'intime as'+'''进库时间''','+'bz as'+'''备''';
这样改
procedure TForm1.FormShow(Sender: TObject);
var
sqr: string;
begin
sqr:='CREATE TABLE #oigl (guig char(10),shl char(10),intime datetime,bz char(50))';
sqr:=sqr+''+'insert into #oigl select guig,shl,intime,bz from gpinlog union';
sqr:=sqr+'select guig,shl,s_intime,bz from czgl_i union';
sqr:=sqr+'select guig,shl,wctime,bz from gdb';
sqr:=sqr+''+'select guig as'+''规格','+'shl as'+''数量','+'intime as'+''进库时间','+'bz as'+''备''';
sqr:=sqr+''+'from #oigl';
...或者这样改
procedure TForm1.FormShow(Sender: TObject);
const
sqr:='CREATE TABLE #oigl (guig char(10),shl char(10),intime datetime,bz char(50))'+
''+'insert into #oigl select guig,shl,intime,bz from gpinlog union'+
'select guig,shl,s_intime,bz from czgl_i union'+
'select guig,shl,wctime,bz from gdb'+
''+'select guig as'+''规格','+'shl as'+''数量','+'intime as'+''进库时间','+'bz as'+''备'''+
''+'from #oigl';
begin
...不过,看了半天,你的字符串还是有问题,仔细查查
最后一行估计他是想用一个表单命令,从表单中读出一个文件数据再合并到变量sqr中。表单命令我还没学,应该是引号用的个数不对。
procedure TForm1.FormShow(Sender: TObject);
var
sqr: string;
begin
sqr:='CREATE TABLE #oigl (guig char(10),shl char(10),intime datetime,bz char(50))';
sqr:=sqr+''+'insert into #oigl select guig,shl,intime,bz from gpinlog union';
sqr:=sqr+'select guig,shl,s_intime,bz from czgl_i union';
sqr:=sqr+'select guig,shl,wctime,bz from gdb';
sqr:=sqr+''+'select guig as'+''规格','+'shl as'+''数量','+'intime as'+''进库时间','+'bz as'+''备''';
sqr:=sqr+''+'from #oigl';
基本格式得像这样 一般的程序体要在begin end之间
建议楼主下载个简单的demo看下吧