Y
yangjj
Unregistered / Unconfirmed
GUEST, unregistred user!
用一个下拉列表,设置字段名,一个EDIT1输入查询内容,
在下拉列表中是中文字段名,但在数据库中用的是E文名,
如何实现查询呀?,哪位大侠能给指点一二?
我用下面的代码不行呀!只能查询第一个字段的内容!
if adoquery1.state<>dsinactive then
adoquery1.close;
adoquery1.sql.clear;
if ed1.text<>'' then
if Cb1.Text='计划编号' then
begin
adoquery1.sql.add('SELECT jh_zb.jh_code, jh_zb.gc_name,'+
'jh_zb.zj_kind, jh_zb.xm_code, jh_zb.ys_bank, jh_zb.jh_data,'+
'jh_zb.dw_uint, jh_zb.pz_file, jh_zb.bb_unit, jh_zb.jb_person,'+
'jh_zb.bz_data, jh_fb.sb_code, jh_fb.sb_name,'+
'jh_fb.gg_type,jh_fb.jl_unit, jh_fb.sl_amount, jh_fb.dj_price,'+
'jh_fb.gh_unit, jh_fb.jh_person, jh_fb.bz_memo1 '+
'FROM jh_zb LEFT JOIN jh_fb ON jh_zb.jh_code = jh_fb.jh_code '+
'where jh_zb.jh_code = '''+ed1.text+''' order by jh_zb.jh_code ASC');
adoquery1.open;
end;
if Cb1.Text='编报单位' then
begin
adoquery1.sql.add('SELECT jh_zb.jh_code, jh_zb.gc_name,'+
'jh_zb.zj_kind, jh_zb.xm_code, jh_zb.ys_bank, jh_zb.jh_data,'+
'jh_zb.dw_uint, jh_zb.pz_file, jh_zb.bb_unit, jh_zb.jb_person,'+
'jh_zb.bz_data, jh_fb.sb_code, jh_fb.sb_name,'+
'jh_fb.gg_type,jh_fb.jl_unit, jh_fb.sl_amount, jh_fb.dj_price,'+
'jh_fb.gh_unit, jh_fb.jh_person, jh_fb.bz_memo1 '+
'FROM jh_zb LEFT JOIN jh_fb ON jh_zb.jh_code = jh_fb.jh_code '+
'where jh_zb.bb_unit = '''+ed1.text+''' order by jh_zb.jh_code ASC');
adoquery1.open;
end;
在下拉列表中是中文字段名,但在数据库中用的是E文名,
如何实现查询呀?,哪位大侠能给指点一二?
我用下面的代码不行呀!只能查询第一个字段的内容!
if adoquery1.state<>dsinactive then
adoquery1.close;
adoquery1.sql.clear;
if ed1.text<>'' then
if Cb1.Text='计划编号' then
begin
adoquery1.sql.add('SELECT jh_zb.jh_code, jh_zb.gc_name,'+
'jh_zb.zj_kind, jh_zb.xm_code, jh_zb.ys_bank, jh_zb.jh_data,'+
'jh_zb.dw_uint, jh_zb.pz_file, jh_zb.bb_unit, jh_zb.jb_person,'+
'jh_zb.bz_data, jh_fb.sb_code, jh_fb.sb_name,'+
'jh_fb.gg_type,jh_fb.jl_unit, jh_fb.sl_amount, jh_fb.dj_price,'+
'jh_fb.gh_unit, jh_fb.jh_person, jh_fb.bz_memo1 '+
'FROM jh_zb LEFT JOIN jh_fb ON jh_zb.jh_code = jh_fb.jh_code '+
'where jh_zb.jh_code = '''+ed1.text+''' order by jh_zb.jh_code ASC');
adoquery1.open;
end;
if Cb1.Text='编报单位' then
begin
adoquery1.sql.add('SELECT jh_zb.jh_code, jh_zb.gc_name,'+
'jh_zb.zj_kind, jh_zb.xm_code, jh_zb.ys_bank, jh_zb.jh_data,'+
'jh_zb.dw_uint, jh_zb.pz_file, jh_zb.bb_unit, jh_zb.jb_person,'+
'jh_zb.bz_data, jh_fb.sb_code, jh_fb.sb_name,'+
'jh_fb.gg_type,jh_fb.jl_unit, jh_fb.sl_amount, jh_fb.dj_price,'+
'jh_fb.gh_unit, jh_fb.jh_person, jh_fb.bz_memo1 '+
'FROM jh_zb LEFT JOIN jh_fb ON jh_zb.jh_code = jh_fb.jh_code '+
'where jh_zb.bb_unit = '''+ed1.text+''' order by jh_zb.jh_code ASC');
adoquery1.open;
end;