老总交代任务,把文本导入SQL,我写了个简易的工具   可是每次只能导入第一行,望各位大虾指教一下 谢谢了!procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
 TxtFile:TextFile;    //定义文本变量
 ch:Char;
 begin
   with adoquery1 do //打开数据库
   adoquery1.Close;
   adoquery1.SQL.Add('select * from jzgdzcxx');
   adoquery1.open;
   assignfile (txtfile,'d:/1.txt');   //将文本分配给变量
   reset(txtfile);                      //打开文本变量
    str:='';
   while not eof(txtfile) do    //只要文本没有结束 就循环转换
   begin
    readln (txtfile,ch);        //从文本读第一个字符
    if ch<>char(13) then       //判断是否为回车
     str:=str+ch               //不是回车 继续读下一个
     else
     begin
     table1.Active:=true;     //是回车 表明读完一行 此时str为一行记录
     table1.Append;
     table1.Edit;
     table1.fieldbyname('编号').AsString:=copy(str,1,12);
     table1.FieldByName('日期').AsString:=copy(str,14,4)+'/'+copy(str,18,2)+'/'+copy(str,20,2);
     table1.FieldByName('数据').AsString:=copy(str,23,16);
     table1.Post;
     readln (txtfile,ch);
     str:='';
     next;
     end;
     end;
     end;另外  加了个清空按钮  点击后 再导入,连一行都导入不了了···procedure TForm1.Button2Click(Sender: TObject);
begin
  with adoquery1 do
     close;
     adoquery1.sql.add('delete from jzgdzcxx');
     adoquery1.ExecSQL;
end;
end.