我在将ACCESS数据库导入到LISBOX时,有问题了,请大侠帮忙看看。。。
我想让ACCESS数据库里的内容显示在Listbox里,可是编译的时候经常出错。我在我的窗体里只放了一个Panel,然后在它上面放了个Button和Listbox。和链接数据库的ADO组件。下面是我写的程序:unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
ListBox1: TListBox;
Button1: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select * from yctab';
adoquery1.Open;
ADOQuery1.Sort:='point_id';
for i:=adoquery1.RecordCount-1 downto 0 do begin
adoquery1.Last;
adoquery1.Delete;
end;
while not eof do begin
listbox1.items.add('point_id'.integer);
next;
end;
close;
end;
end.