我通过表Table1创建了一个ADODataSet1(结构),然后从ABC.txt文件中一次读入了若干记录,有无办法将这些记录增加至Table1中? 在线等待....

解决方案 »

  1.   

    var
      Field:TField;
    begin
        Table1.Open;
        with ADODataSet1 do begin
          First;
          while not eof do
          begin
            Table1.Append;
            for i:= 0 to Table1.FieldCount-1 do
            begin
              Field:= FindField(Table1.Fields[i].FieldName);
              if Field <> nil then
              begin
                if not Field.ReadOnly then
                  Table1.FieldByName(Field.FieldName).Value:=FieldByName(Field.FieldName).Value;
              end;
            end;
            Next;
          end;
        end;
        Table1.ApplyUpdates(1);
        Table1.Close;
      except
      end;
    end;