主题:查询的结果无法显示到DBGridEh中
大家来帮我看看下面查询模块的代码,查询之前DBGridEh1中显示的是当前表中所有记录,执行查询后DBGridEh1中显示的记录不变,通过测试发现查询语句能正确执行,但用了很多方法都不能刷新数据到DBGridEh1中显示。(插入、修改、删除操作执行完后DBGridEh1都能正确显示更新后的记录)
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);
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);
end
end
end;