procedure TForm1.FormShow(Sender: TObject); var i:integer; begin with ADOQuery1 do begin Close; sql.Clear ; sql.Add('select xh from xs'); open; first; while not eof do begin combobox1.Items.Add(fieldbyname('xh').AsString ); next; end; end; end;end.代码改了一下。
代码改成procedure TForm1.FormShow(Sender: TObject); var I:Integer; begin with ADOQuery1 do begin Close; sql.Clear ; sql.Add('select xh from xs'); try open; first; while not eof do begin combobox1.Items.Add(fieldbyname('xh').AsString ); next; end; finally Close; end; end; end;
代码就一点 就三个控件 ADOConnection1,ADOQuery1,ComboBox1
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
ComboBox1: TComboBox;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject);
var
i:integer;
begin
with ADOQuery1 do
begin
sql.Clear ;
sql.Add('select xh from xs');
open;
first;
for i:=0 to recordcount-1 do
begin
combobox1.Items.Add(fieldbyname('xh').AsString );
next;
end;
close;
end;
end;end.
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Adoconnection1.connected:=False;
end;是这个原因吗? Adoconnection1没关闭 才点几下 就卡? 我是2G内存
但是不关 也不至于卡住一分钟吧? 就连接access
现在数据量大了
你在设计期就直接open数据库
你运行cmp,ping一下你的sql服务器看看有没有丢包,另外速度是不是小于128ms,如果不是,问题出在网线和交换机上
delphi7,连本机的数据库啊,
而且只有点关闭按钮才会卡,在delphi环境按CTRL+F2 关闭正常 不卡在状态栏,右键点exe关闭 也是正常的 不卡
var
i:integer;
begin
with ADOQuery1 do
begin
Close;
sql.Clear ;
sql.Add('select xh from xs');
open;
first;
while not eof do
begin
combobox1.Items.Add(fieldbyname('xh').AsString );
next;
end;
end;
end;end.代码改了一下。
代码改成procedure TForm1.FormShow(Sender: TObject);
var
I:Integer;
begin
with ADOQuery1 do
begin
Close;
sql.Clear ;
sql.Add('select xh from xs');
try
open;
first;
while not eof do
begin
combobox1.Items.Add(fieldbyname('xh').AsString );
next;
end;
finally
Close;
end;
end;
end;
ACCESS数据库或者该数据表是不是打开被占用?