首页 > 代码库 > 保存工资到记事本的写法

保存工资到记事本的写法

需要加一个savedialog组件然后写入以下代码

 

 技术分享

 

 1 procedure TForm3.N7Click(Sender: TObject);
 2 var
 3 MyList: TStringList;
 4 MyAdoq: TADOQuery;
 5 I: Integer;
 6 myfieldvalue,myfieldName,mystr: string;
 7 begin
 8   MyList := TStringList.Create;
 9   MyAdoq := TADOQuery.Create(nil);
10   MyList.Clear;
11   try
12       MyAdoq.Connection := frmDataPool.ADOConnection1;
13       mystr:=‘‘ ;
14       myList.Clear;
15       frmDataPool.qry工资表.First;
16       while not frmDataPool.qry工资表.Eof do
17        begin
18        for i := 0 to frmDataPool.qry工资表.FieldDefs.Count - 1 do
19        begin
20        //myfieldName := frmDataPool.qry工资表.FieldDefs[i].Name;
21        myfieldName:= frmDataPool.qry工资表.Fields[I].FieldName;
22        myfieldvalue:= frmDataPool.qry工资表.FieldByName(myfieldName).AsString;
23        mystr:=mystr+myfieldname+‘‘+‘:‘+‘‘+‘(‘+myfieldvalue+‘)‘+‘‘+‘;‘;
24        //ShowMessage(myfieldName);
25        //ShowMessage(myfieldvalue);
26        //ShowMessage(mystr);
27        end;
28        myList.Add(mystr);
29        mystr:=‘‘ ;
30        frmDataPool.qry工资表.Next;
31        end;
34       if SaveDialog1.Execute then
35       MyList.SaveToFile(SaveDialog1.FileName);
36   finally
37   MyList.Free;
38   MyAdoq.Free;
39   end;
40 end;

 

保存工资到记事本的写法