求助一个ComboBox问题!!!急!!~~在线的大哥们都进来看看

yaccor 2005-07-02 09:35:49
with Qry_Employee,ComboBox1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from T_Employee'); //T_Employee'包含name,salary两字段
Open;
Clear;
First;
while not eof do
begin
Items.Add(FieldByName('name').AsString);
Edit1.Text:=FieldByName('salary').asstring;
Next;
end;
end;
例如我在ComboBox1中选择员工名称“张三”,我想在旁边一个Edit1文本框中显示
张三的工资,但是我这个代码显示的结果始终是最后一个员工的薪水,请问如何修改??
...全文
118 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
leanIxj 2005-07-02
  • 打赏
  • 举报
回复
写在COMBOBX的ONCHANGE事件中
with Qry_Employee,ComboBox1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from T_Employee where name="'
+combobox1.Items[combobox1.itemindex].text+'"');//获得这个人的记录
Edit1.Text:=FieldByName('salary').asstring;
end;
yaccor 2005-07-02
  • 打赏
  • 举报
回复
with Frm_Data.Qry_Temp do
begin
Close;
SQL.Clear;
SQL.Add('select coin from T_EnrolType where type='''+Combo_Type.Text+'''');
Open;
Edit_Money.Text:=FloatToStr(Fieldvalues['Coin']);
end;
这样问题解决了。谢谢,看来我的SQL太菜了,
coffee36 2005-07-02
  • 打赏
  • 举报
回复
写在COMBOBX的ONCHANGE事件中
with Qry_Employee,ComboBox1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from T_Employee');
Open;
Locate('name',combobox1.Items[combobox1.itemindex],[]);//定位到你选择的记录上
Edit1.Text:=FieldByName('salary').asstring;
end;
lishery 2005-07-02
  • 打赏
  • 举报
回复
while not eof do
begin
Edit1.Text:=FieldByName('salary').asstring;
Next;
end;
Edit1文本框中显示的当然是最后工资
在Edit1文本框的OnEnter事件中,
with Qry_Employee do
begin
Close;
SQL.Clear;
SQL.Add('select Salary from T_Employee');
SQL.Add('Where name='''+combobox1.text+'''');
Open;
Edit1.text:=FloatToString(Fieldvalues['Salary']);
end;



828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧