how so that I can remove / modify fields in the DB Grid permanently? I use this code: NB : CDS = ClientDataSet DBG = DBGrid Database I use is *.xml
uses
Windows, SysUtils, Forms, ExtCtrls, Buttons, DB, DBClient, DBGrids,
Grids, Controls, StdCtrls, Dialogs, Classes;
type
TForm1 = class(TForm)
B2: TSpeedButton;
B3: TSpeedButton;
DS: TDataSource;
CDS: TClientDataSet;
DBG: TDBGrid;
SD: TSaveDialog;
RG: TRadioGroup;
E1: TEdit;
E2: TEdit;
L1: TLabel;
L2: TLabel;
B1: TSpeedButton;
B4: TSpeedButton;
B5: TSpeedButton;
OD: TOpenDialog;
var
FN, FDragOfs: Integer;
FDragging: Boolean;
procedure TForm1.FormShow(Sender: TObject);
begin
FN := 1;
RG.ItemIndex := 0;
end;
on Button Create --->
try
FN := FN + 1;
CDS.Active := false;
with CDS.FieldDefs.AddFieldDef do
begin
Name := E1.Text;
case RG.ItemIndex of
0 :
begin
DataType := ftString;
Size := StrToInt(E2.Text);
end;
1 :
DataType := ftInteger;
end;
end;
CDS.CreateDataSet;
E1.Text := 'Field'+IntToStr(FN);
RG.ItemIndex :=0;
finally
CDS.Active := True;
end;
on Button Export To File ---->
if not SD.Execute then
exit
else
begin
CDS.SaveToFile(SD.filename,dfxml);
CDS.Active := false;
CDS.FileName := SD.FileName;
on Button Delete --->
CDS.Fields.Remove (DBG.Columns.Items [DBG.SelectedIndex] .Field);
//DBG.Columns.Delete(DBG.SelectedIndex);
DBG.Columns.RebuildColumns;
DB Structur e.g like this :
<?xml version="1.0" standalone="yes"?>
<DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="Number" fieldtype="i4"/>
<FIELD attrname="Date" fieldtype="string" WIDTH="20"/>
<FIELD attrname="Name" fieldtype="string" WIDTH="20"/>
<FIELD attrname="Phone" fieldtype="string" WIDTH="20"/>
<FIELD attrname="Address" fieldtype="string" WIDTH="20"/>
<FIELD attrname="Manager" fieldtype="string" WIDTH="20"/>
</FIELDS>
<PARAMS/>
</METADATA>
<ROWDATA>
</ROWDATA>
</DATAPACKET>
so the question of how way I can remove / replace(rename or modified) with another name field that I do not want when Run-Time, i want to delete this line. example:
<FIELD attrname = "Date" fieldtype = "string" WIDTH = "20" />
after I remove Field does not appear, but when I took my application and re-run the database load sa'at back again as before.
sorry about my English.
Aucun commentaire:
Enregistrer un commentaire