delphi 关于获取 ADOQuery1 数据的问题

来源:百度知道 编辑:UC知道 时间:2024/06/16 19:05:14
ADOQuery.first;
while not ADOQuery1.eof do
begin
Combobox1.items.add(ADOQuery1.fieldbyname('xx').asstring);
ADOQuery1.next;
end;
以上代码我使用后发现最后ComboBox1获取到的结果是最后一个数据,而之前的数据没有获取到,我加了ADOQuery.first也没有效果,请大家帮我找找原因,谢谢了~

这样试试:

for i := 0 to adoquery1.RecordCount -1 do
begin
Combobox1.items.add(ADOQuery1.fieldbyname('xx').asstring);
adoquery1.Next;
end;

不过看你代码没有太大问题,如果以上代码也不行,建议看看相关上下文代码!

wish you Luck!

试试这个方法
Combobox1.Clear;
Combobox1.Properties.Items.Add('>');
Combobox1.Properties.Items.Add('<');
Combobox1.Properties.Items.Add('=');
Combobox1.Properties.Items.Add('>=');
Combobox1.Properties.Items.Add('<=');
Combobox1.ItemIndex:=0;

你的这个循环语句是没有问题,
我就是这样用的,
我觉得是你的ADOQUERY里的SQL语句有问题把?

代码没有问题,查看其他问题