SQL语句中的参数不能是表名或字段名或函数名. 你应该用动态生成的方法来作: Query1.SQL.Text := Format('Create table s (CuID int)',[TBN]); 轻风又伤心了:2002-06-04 ____ ____ \ p \ / g / \ l \_/ n / \ a o / \ i s / \ n / \_/
再来 procedure TForm1.CreateTableReport(tt:string); begin with ADOQuery2 do begin Close; SQL.Clear; SQL.Add('Create Table '+tt+' (场地代码 char(4) not null, '); SQL.Add('应收款 money default 0 not null, '); SQL.Add('汇回款 money default 0 not null, 未收款 money default 0 not null,日期 datetime default 2002-1-1 not null)'); ExecSQL; end; end;
我就是这样的啊 var TBN : String; begin TBN := 'table1'; …… ADOQuery1.SQL.Add('create table '+''+TBN+''+'(CuID int)') ……end;
你应该用动态生成的方法来作:
Query1.SQL.Text := Format('Create table s (CuID int)',[TBN]); 轻风又伤心了:2002-06-04
____ ____
\ p \ / g /
\ l \_/ n /
\ a o /
\ i s /
\ n /
\_/
var strtablename:string;
strtablename:='tablename';
adoquery1.active:=false;
.........
adoquery1.sql.add('create table');
adoquery1.sql.add(strtablename);
adoquery1.sql.add('(xx int)');
.........
'select * from '+cddaima
cddaima:是string 型的变量
procedure TForm1.CreateTableReport(tt:string);
begin
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('Create Table '+tt+' (场地代码 char(4) not null, ');
SQL.Add('应收款 money default 0 not null, ');
SQL.Add('汇回款 money default 0 not null, 未收款 money default 0 not null,日期 datetime default 2002-1-1 not null)');
ExecSQL;
end;
end;
var TBN : String;
begin
TBN := 'table1';
……
ADOQuery1.SQL.Add('create table '+''+TBN+''+'(CuID int)')
……end;
ADOQuery1.SQL.Add('create table '+TBN+' (CuID int)')