标题:查询结果不能显示到DBGridEh中
只看楼主
Benjamin416
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-5-17
 问题点数:0 回复次数:0 
查询结果不能显示到DBGridEh中
楼主
大家来帮我看看下面查询模块的代码,查询之前DBGridEh1中显示的是当前表中所有记录,执行查询后DBGridEh1中显示的记录不变,通过测试发现查询语句能正确执行,但用了很多方法都不能刷新数据到DBGridEh1中显示。(插入、修改、删除操作执行完后DBGridEh1都能正确显示更新后的记录)
procedure TF_Main.Button3Click(Sender: TObject);
begin
DataModule_Navig.ADODataSet_AircraftFailure.close;
DataModule_Navig.ADODataSet_AircraftFailure.CommandText:='select * from TAB_FHA_AircraftFailure';
DataModule_Navig.ADODataSet_AircraftFailure.open;
if F_NewAircraftInfo= nil then F_NewAircraftInfo:=TF_NewAircraftInfo.create(application);
F_NewAircraftInfo.Caption:='整机功能信息修改';
with F_NewAircraftInfo do
begin
SpeedButton1.Visible:=true;
SpeedButton2.Visible:=true;

//dbgrideh1.SelectedIndex
//DBGridEh1.datasource.dataset.next;
//F_Main.DbGridEh1.DataSource.DataSet.MoveBy(1);//移动一行
Edit1.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['Aircraft'];
Edit2.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['Function'];
Edit3.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['FailureCondition'];
Edit4.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['NO'];
Edit5.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['FlightPhase'];
Edit6.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['EffectOnOtherSystem'];
Edit7.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['EffectOnAircraft'];
Edit8.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['SecurityClassification'];
Edit9.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['AnalysisMethods'];
Memo1.Text:=DataModule_Navig.ADODataSet_AircraftFailure.FieldValues['Remarks'];
end;
F_NewAircraftInfo.ShowModal;
end;

procedure TF_Main.Button2Click(Sender: TObject);
begin
DataModule_Navig.ADODataSet_AircraftFailure.close;
DataModule_Navig.ADODataSet_AircraftFailure.CommandText:='select * from TAB_FHA_AircraftFailure';
DataModule_Navig.ADODataSet_AircraftFailure.open;
if DataModule_Navig.ADODataSet_AircraftFailure.RecordCount=0 then
messagebox(handle,'无记录','警告',MB_OK)
else
begin
if Messagebox(handle,'你确实要删除该记录?','警告',MB_YESNO)=IDYES then
begin
DataModule_Navig.ADODataSet_AircraftFailure.Delete;
messagebox(handle,'你已删除了该记录','提示',MB_OK);

//DataModule_Navig.ADODataSet_AircraftFailure.Active := false;
//DataModule_Navig.ADODataSet_AircraftFailure.Active := true;
DataModule_Navig.ADOQuery_AircraftFailure.Active:=false;
DataModule_Navig.ADOQuery_AircraftFailure.Active:=true;
end
end



end;



procedure TF_Main.Button4Click(Sender: TObject);
var strata1,strata2: string;
pc:pchar;
begin
strata1:=trim(Combobox1.Text);
strata2:=trim(Combobox2.Text);

if strata2='' then
begin
if strata1='' then
begin
Messagebox(handle,'请选择机型或填入功能危险编号!','提示',MB_OK);
exit;
end
else
begin
DataModule_Navig.ADODataSet_AircraftFailure.Close;
DataModule_Navig.ADODataSet_AircraftFailure.CommandText:='select * from TAB_FHA_AircraftFailure where TAB_FHA_AircraftFailure.Aircraft='''+strata1+'''';
DataModule_Navig.ADODataSet_AircraftFailure.Open;
pc := pchar(IntToStr(DataModule_Navig.ADODataSet_AircraftFailure.RecordCount));
Messagebox(handle,pc,'提示',MB_OK);
DBGridEh1.Refresh;
if DataModule_Navig.ADODataSet_AircraftFailure.RecordCount=0 then
messagebox(handle,'无此机型记录','提示',MB_OK);
end
end
else
begin
if strata1='' then
begin
DataModule_Navig.ADODataSet_AircraftFailure.Close;
DataModule_Navig.ADODataSet_AircraftFailure.CommandText:='select * from TAB_FHA_AircraftFailure where TAB_FHA_AircraftFailure.No='''+strata2+'''';
DataModule_Navig.ADODataSet_AircraftFailure.Open;
pc := pchar(IntToStr(DataModule_Navig.ADODataSet_AircraftFailure.RecordCount));
Messagebox(handle,pc,'提示',MB_OK);
if DataModule_Navig.ADODataSet_AircraftFailure.RecordCount=0 then
messagebox(handle,'无此功能危险编号记录','提示',MB_OK);
end
else
begin
DataModule_Navig.ADODataSet_AircraftFailure.Close;
DataModule_Navig.ADODataSet_AircraftFailure.CommandText:='select * from TAB_FHA_AircraftFailure where TAB_FHA_AircraftFailure.No='''+strata2+''' and TAB_FHA_AircraftFailure.Aircraft='''+strata1+'''';
DataModule_Navig.ADODataSet_AircraftFailure.Open;
pc := pchar(IntToStr(DataModule_Navig.ADODataSet_AircraftFailure.RecordCount));
Messagebox(handle,pc,'提示',MB_OK);
if DataModule_Navig.ADODataSet_AircraftFailure.RecordCount=0 then
messagebox(handle,'此机型下无此功能危险编号记录','提示',MB_OK);

//DataModule_Navig.ADOQuery_AircraftFailure.Active:=false;
//DataModule_Navig.ADOQuery_AircraftFailure.Active:=true;

//DataModule_Navig.ADOQuery_AircraftFailure.Requery();

//DataModule_Navig.ADOQuery_AircraftFailure.Close;
//DataModule_Navig.ADOQuery_AircraftFailure.Open;
end
end


end;
搜索更多相关主题的帖子: 记录 测试 procedure border center 
2006-05-17 22:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-65128-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.146527 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved