adoqry := TADOQuery.Create(nil);
try
adoqry.Connection := ADOConnection1;
adoqry.Close;
adoqry.SQL.Clear;
adoqry.SQL.Add('select a,b from table');
adoqry.Open;
while not adoqry.Eof do
begin
if adoqry.FieldByName('a').AsString = 'message1' then
begin
btxt.Text :=adoqry.FieldByName('b').AsString;
end
end;
adoqry.Close;
end为什么 adoqry.Close 到这个地方就出错。说什么 eof,bof。我这个table是个空表。
用的是ado。
try
adoqry.Connection := ADOConnection1;
adoqry.Close;
adoqry.SQL.Clear;
adoqry.SQL.Add('select a,b from table');
adoqry.Open;
while not adoqry.Eof do
begin
if adoqry.FieldByName('a').AsString = 'message1' then
begin
btxt.Text :=adoqry.FieldByName('b').AsString;
end
end;
adoqry.Close;
end为什么 adoqry.Close 到这个地方就出错。说什么 eof,bof。我这个table是个空表。
用的是ado。
解决方案 »
- delphi能在win7上运行吗?跟xp上开发有什么区别没有?
- 用XMLHTTP对象读取网页内容出现乱码
- 请教mscomm与plc的串口通讯
- 请教!winsock连接服务器后使用recv时出现死机
- type library 中的数据类型有些挺熟的(如:DATE)但有些我都没见过(如:FONTITALIC、BSTR),这些都是些什么类型啊,哪里有这方面的资
- 打印问题!
- label1.caption:=string(inttohex(10));为什么不行?
- delphi 程序资源替换问题
- 那有中文帮助下载?
- 不为名不为利,只想创立一个delphi小组,在兴趣的进来!!!!!!!
- 从一个库向另外一个数据库导数据
- cxgrid问题
try
adoqry.Connection := ADOConnection1;
adoqry.Close;
adoqry.SQL.Clear;
adoqry.SQL.Add('select a,b from table');
adoqry.Open;
while not adoqry.Eof do
begin
if adoqry.FieldByName('a').AsString = 'message1' then
begin
btxt.Text :=adoqry.FieldByName('b').AsString;
end
adoqry.next;
end;
adoqry.Close;
finally
adoqry.free;
end
insert into [table]
select 'message1','kaikai' union all
select 'kkkk','BBBB'D代码:procedure TForm1.Button1Click(Sender: TObject);
var
adoqry:Tadoquery;
begin
adoqry := TADOQuery.Create(nil);
with adoqry do
begin
try
Connection:=ADOConnection1;
Close;
SQL.Text:='select a,b from [table]'; {如果你的表名是table,那么要加上中括号,不然open时会出错}
Open;
while not Eof do
begin
if FieldByName('a').AsString = 'message1' then
btxt.Text :=FieldByName('b').AsString; {btxt.Text='kaikai'}
Next; {须有next,不然会死循环}
end;
Close;
finally
Free; {释放}
end;
end;
end;
adoqry.Connection := ADOConnection1;
try
with adoqry do
begin
close;
sql.text := 'select a,b from table';
Open;
while not eof do
begin
if adoqry.FieldByName('a').AsString = 'message1' then
begin
btxt.Text :=adoqry.FieldByName('b').AsString;
end
Next;
end;
end;
finally
adoqry.free;
end;
我用的是delphi5,ado没有更新的缘故。
更新了以后就好了。