rt 请写几个例子

解决方案 »

  1.   

    FieldByName是根据名字查找字段对象的,Fields是根据下标来读取字段对象,Fields由于没有查找过程,效率会比FieldByName高。
      

  2.   

    根据索引Fields[0]效率高,FieldByName是要根据name值去循环比较找到对应的字段
      

  3.   

    Fields 就好比你取数组元素。
    FieldByName 就好比for循环查找一样。
      

  4.   

    procedure TForm1.Button2Click(Sender: TObject);var
       i: Integer;
       Info: String;
    begin
       Info := 'The fields of table ' + Table1.TableName + 
               ' are:'#13#10#13#10;
       for i := 0 to Table1.FieldCount - 1 do
          Info := Info + Table1.Fields[i].FieldName + #13#10;
      ShowMessage(Info);
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ClientDataSet1.Insert;
      ClientDataSet1.FieldByName('QUANTITY').AsInteger := StrToInt(Edit1.Text);
      ClientDataSet1.Post;end;