此程序为什么会死机??

Jackasdf 2005-06-09 09:27:46

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Buttons, DB, ADODB;

type
TForm1 = class(TForm)
ListView1: TListView;
BitBtn1: TBitBtn;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from tzb');
open;

listview1.Items.Clear ;
while not eof do
with listview1.Items.Add do
begin
caption:=fieldByName('jszh').AsString;
subitems.Add(fieldByName('xm').AsString);
subitems.Add(fieldByName('sfzh').AsString);
end;
next
end;


end;


end.我一运行此程序就死机,何解
...全文
138 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sato 2005-07-07
  • 打赏
  • 举报
回复
把with去掉,再调试,就能发现问题了!
bai11 2005-07-05
  • 打赏
  • 举报
回复
没有next
DelphiSharp 2005-07-04
  • 打赏
  • 举报
回复
少用with 看不出有多大好处
xiaoyanggonghui 2005-07-04
  • 打赏
  • 举报
回复
呵呵 楼上的兄弟 查询出来 默认的就是第一笔
hellolongbin 2005-06-10
  • 打赏
  • 举报
回复
open;
first;//你忘了这句;
while not eof do
begin //这句也应该写上
dosomething;
next;
end;
ys19011 2005-06-09
  • 打赏
  • 举报
回复
同志这就不是能力的问题了,
这种错误是要挨鞭子的
呵呵
herman~~ 2005-06-09
  • 打赏
  • 举报
回复
同意 pilicat(delphi迷的方法
javafelia 2005-06-09
  • 打赏
  • 举报
回复
我做了一下,没有问题!
pilicat 2005-06-09
  • 打赏
  • 举报
回复
呵呵,死循环了,当然死了,改为如下:

while not eof do
begin//加个Begin
with listview1.Items.Add do
begin
caption:=fieldByName('jszh').AsString;
subitems.Add(fieldByName('xm').AsString);
subitems.Add(fieldByName('sfzh').AsString);
end;
next;
end;//加个End,主要是把上面的next包在里面。
wdqxxx 2005-06-09
  • 打赏
  • 举报
回复
真的吗?我正需要一个能死机的程序!我试试。

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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