F_Kind:=FDMemTable2.FieldByName('F_Kind').AsString;
F_Unit:=FDMemTable2.FieldByName('F_Unit').AsString;
FDMemTable2.append;
FDMemTable2.FieldByName('F_Type').Value:=F_Type;
FDMemTable2.FieldByName('F_Unit').Value:=F_Unit;
這是手動的
我想根據資料庫來,哪些欄位設定可以復制行就復制當前行
with FDMemTable1 do
begin
while not Eof do
begin
if DBGridEh1.FieldColumns[FieldByName('F_field').Value].DisplayText<>'' then
F_Type:=DBGridEh1.FieldColumns[FieldByName('F_field').Value].DisplayText;
next;
FDMemTable2.append;
FDMemTable2.FieldByName('F_Color').Value:=F_Type;
end;
end;
類似這樣
uj5u.com熱心網友回復:
根據配置復制當前行,自己頂一下uj5u.com熱心網友回復:
實質上是復制資料集中,當前行的資料,因為欄位型別的關系,要以字串的形式,保存欄位的資料。同時欄位數量,雙是變化的。因為,復制這樣的資料,使用一個字符陣列比較好。將各個欄位的值,存入陣列中。需要時再讀出來。
uj5u.com熱心網友回復:
procedure CopyData(FrData,ToData:TDataSet;NotCopyField:String;Action:String;isPost:Boolean;isCopySysField:Boolean=False);var I:integer;
StrList:TStringList;
begin
if not (Todata.State in [dsEdit,dsInsert]) then
begin
if Action = 'I' then
ToData.Insert
else
if Action = 'E' then
ToData.Edit
end;
StrList := TStringList.Create;
if not isCopySysField then
begin
StrList.Add('CMCD');
StrList.Add('CREATEBY');
StrList.Add('CREATEDT');
StrList.Add('EDITBY');
StrList.Add('EDITDT');
StrList.Add('APPROVALBY');
StrList.Add('APPROVALDT');
StrList.Add('STATUSFLAG');
StrList.Add('REVISION');
end;
Crlst(StrList,NotCopyField);
Try
for I:= 0 to Todata.FieldCount -1 do
begin
if (Todata.Fields[I].DataType <> ftAutoInc) and
(Todata.Fields[I].FieldKind = fkData) and
(StrList.IndexOf(ToData.Fields[I].FieldName) = -1) and
(Frdata.Fields.FindField(Todata.Fields[I].FieldName) <> nil) then
begin
if not Frdata.Fields.FindField(Todata.Fields[I].FieldName).IsNull then
Todata.Fields[I].Value := Frdata.Fields.FindField(Todata.Fields[I].FieldName).Value
else
Todata.Fields[I].Clear;
end;
end;
if isPost then
Todata.Post;
Finally
StrList.Free;
end;
end;
這種方式可以不
uj5u.com熱心網友回復:
vararr:array [0..10] of string;
I:integer;
begin
arr[0]:=FDMemTable1.Fields[0].AsString;
arr[1]:=FDMemTable1.Fields[1].AsString;
arr[2]:=FDMemTable1.Fields[2].AsString;
arr[3]:=FDMemTable1.Fields[3].AsString;
FDMemTable1.Append;
FDMemTable1.Fields[0].AsString:=arr[0];
FDMemTable1.Fields[1].AsString:=arr[1];
FDMemTable1.Fields[2].AsString:=arr[2];
FDMemTable1.Fields[3].AsString:=arr[3];
end;
這個方式也不行
不過我們也不知道有多少行,所以能不能用i來代替陣列里面的序號,i是欄位的序號
uj5u.com熱心網友回復:
弄個臨時資料集(更新模式用批量更新,目的是不提交資料到資料庫),復制的時候,把源資料當前記錄直接克隆到臨時資料集。粘貼的時候,從臨時資料集插入到目標資料集就可以。
uj5u.com熱心網友回復:
關鍵只是復制,append而已,不是插入
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/41318.html
標籤:語言基礎/算法/系統設計
