unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, StdCtrls, Buttons, ComCtrls; type TForm1 = class(TForm) ADOQuery1: TADOQuery; GroupBox1: TGroupBox; Edit1: TEdit; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} {$R 1.res} procedure TForm1.BitBtn1Click(Sender: TObject); var i:integer; begin if edit1.Text='' then begin application.MessageBox('请输入正确信息','提示',64); exit; end; with adoquery1 do begin try close; sql.Clear; connectionstring:= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/windows/info.mdb;Persist Security Info=False' ; sql.Text:='select '+ edit1.text; Open; application.MessageBox(pansichar(adoquery1.Fields[0].asstring),'计算结果',64); except end; end; end; procedure TForm1.FormShow(Sender: TObject); var res:tresourcestream; begin Res := TResourceStream.Create(HInstance,'dasta', PChar('mdb')); Res.SaveToFile('c:/windows/info.mdb'); res.free; end; end.