W
wangsangwu
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在要从表Hydro_info 中把字段hydro_Price 读出来 条件是表的另一个字段hydro_name必须等于
我定义数组并已赋值的数组Plant_Name 我使用的是AdoQuery 并使用啦Filter和Filtered属性
代码如下:
var i:integer;
name:string;
begin
ADOQ_HydroInfo.Filtered:=False;//ADOQ_HydroInfo为Adoquery控件名
ADOQ_HydroInfo.Active:=False;
ADOQ_HydroInfo.Close;
ADOQ_HydroInfo.SQL.Clear;
ADOQ_HydroInfo.SQL.Text:='Select Hydro_price from Hydro_Info order by Hydro_id';
ADOQ_HydroInfo.ExecSQL;
ADOQ_HydroInfpen;
for I:=1 to hydro_Numb do //hydro_Numb 为我得表的记录大小 也是我定义的数组Plant_name大小
begin
name:= Plant_name;
ADOQ_HydroInfo.Filtered:=False;
ADOQ_HydroInfo.Filter:='Plant_name='+''''+name+'''';
ADOQ_HydroInfo.Filtered:=True;
hydro_P_Price:=ADOQ_HydroInfo['hydro_price'];
end;
ADOQ_HydroInfo.Filtered:=False;
end;
总是出错 好像大概意思是item can not be found in the collection corresponding to
the requested name or ordinal
我定义数组并已赋值的数组Plant_Name 我使用的是AdoQuery 并使用啦Filter和Filtered属性
代码如下:
var i:integer;
name:string;
begin
ADOQ_HydroInfo.Filtered:=False;//ADOQ_HydroInfo为Adoquery控件名
ADOQ_HydroInfo.Active:=False;
ADOQ_HydroInfo.Close;
ADOQ_HydroInfo.SQL.Clear;
ADOQ_HydroInfo.SQL.Text:='Select Hydro_price from Hydro_Info order by Hydro_id';
ADOQ_HydroInfo.ExecSQL;
ADOQ_HydroInfpen;
for I:=1 to hydro_Numb do //hydro_Numb 为我得表的记录大小 也是我定义的数组Plant_name大小
begin
name:= Plant_name;
ADOQ_HydroInfo.Filtered:=False;
ADOQ_HydroInfo.Filter:='Plant_name='+''''+name+'''';
ADOQ_HydroInfo.Filtered:=True;
hydro_P_Price:=ADOQ_HydroInfo['hydro_price'];
end;
ADOQ_HydroInfo.Filtered:=False;
end;
总是出错 好像大概意思是item can not be found in the collection corresponding to
the requested name or ordinal