如果是dbedit的话,一定得有个数据源datasource并有一个数据集,(ado)table或者(ado)query,通过sql查询结果把25赋值到一个数据集中,比如select 价格 where 书名=B,查询后直接把dbedit的datasource设置为这个数据集的数据源就可。自己试试吧,很简单的
方法有好多啊.简单的可以用Fieldbyname("价格").AsString就可以啊. 比如: with adodataset1 do begin close; commandtext:=('select * from 表名'); open; edit1.text:=Trim(Fieldbyname("价格").AsString); end;如果用的是dbedit的话.就更简单了.直接绑定就可以啊. 在窗体上添加adoconnection/adodataset/datasource后.设置datasource的connection为adoconnection,设置adodataset的datasource为datasource.后将dbedit的datasource设置为datasource然后将dbedit的FieldName设置成你要显示的字段就可以了.比如设置成价格.
用ado连接后,设置datasource的dataset属性为adotable1,最后将dbedit的datasource
属性设为datasource1,fieldname属性设置为“价格”
比如:
with adodataset1 do
begin
close;
commandtext:=('select * from 表名');
open; edit1.text:=Trim(Fieldbyname("价格").AsString);
end;如果用的是dbedit的话.就更简单了.直接绑定就可以啊.
在窗体上添加adoconnection/adodataset/datasource后.设置datasource的connection为adoconnection,设置adodataset的datasource为datasource.后将dbedit的datasource设置为datasource然后将dbedit的FieldName设置成你要显示的字段就可以了.比如设置成价格.