with Query1 do
begin
close;
sql.clear;
for i:=0 to count do
begin
sql.clear;
///// str:='insert into Table1(f1,f2,f3) values ('+a[i]+','+b[i]+','+c[i]+')';
// 上面这句出错,说string 和 single uncompatible什么的,我的table1的三个字段都是single,
// a[],b[],c[]三个数组也都是single,这样子写不行吗? 数据库是Access的,用的是BDE
////  str:='insert into Texp3 values ('+i*i+','+i*i+','+2*i+')';
// 上面这句也还是错的,那就是说 应该不是数组 的问题 str:='insert into table1 values (0,0,0)';      // 这句就没错,是不是不能用变量??
sql.Add(str);
execsql;
end;    //for
close;
end; //with谢谢了

解决方案 »

  1.   

    str:='insert into Table1(f1,f2,f3) values ('+floattostr(a[i])+','+floattostr(b[i])+','+floattostr(c[i])+')';
    应该这样,先把数字转换为 字符串才行
      

  2.   

    先转成字符串,因为你的SQL语句是个字符串,字符串不能和single类型连接
      

  3.   

    a[i]是数组,不能直接插入表里,要经过转换成string类型才可以!str:='insert into table1 values (0,0,0)'; 中的0可以直接付值的,只要字段类型没错!str:='insert into Texp3 values ('+i*i+','+i*i+','+2*i+')';i*i是浮点型,不能直接用bde插入数据库,也要经过转换成string再插入!
      

  4.   

    SQL语句是字符串,可以用参数传递
    sql.add('insert into table (f1,f2,f3) values (:f1,:f2,:f3)');
    Parameters.ParamByName('f1').value := a[i];
    .......................