to:raymondcen
请帮忙确认下面的代码为何会导致蓝屏错误
//由主窗口传入一个TAdoDataset组件和ListView组件,若查询到结果就显示在主窗口的listview组件中.
unit Unit2;
interface
uses
Classes,DB,AdoDB,ComCtrls,SysUtils;
type
TQueryThread = class(TThread)
private
{ Private declarations }
FDataSet:TAdoDataset;
FQueryException:Exception;
ListView:TListview;
procedure UpdateListView;
protected
procedure Execute; override;
public
constructor Create(Q:TAdoDataSet;LV:TListview); virtual;
end;
implementation
uses
windows,unit3;
{ TQueryThread }
constructor TQueryThread.Create(Q: TAdoDataSet;LV:TListview);
begin
inherited Create(true);
ListView:=LV;
FDataSet := Q;
FDataset.CommandText :='SELECT * FROM TABLE'
FreeOnTerminate:=true;
Resume;
end;
procedure TQueryThread.Execute;
begin
try
FDataset.Open;
if not FdataSet.IsEmpty then
begin
synchronize(Updatelistview);
end;
except
FqueryException:=ExceptObject as Exception;
raise FqueryException.Create('查找过程出错');
end;
end;
procedure TQueryThread.UpdateListView;
var
listItem:TlistItem;
begin
with listview do
begin
while not Fdataset.eof do
begin
listitem:=items.add;
listitem.Caption :='..... '
listitem.SubItems.Add(Fdataset.fieldbyname('A').asstring);
listitem.SubItems.Add(Fdataset.fieldbyname('Br').asstring);
//.......
Fdataset.next;
end;
end;
end;
end.