delphi 以下代码查询按钮第1次点击报file not found错误,点击第2次以后就正常查询出来了,搞不懂为什么
varForm1:TForm1;mmo1:string;implementation{$R*.dfm}procedureTForm1.Button2Click(Sende...
var
Form1: TForm1;
mmo1:string;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
SN:string;
begin
begin
if Memo1.Lines.count>1000 then
ShowMessage('警告:查询数不能超过1000')
else
clientdataset1.Close;
mmo1:=copy(memo1.Text,1,Length(Memo1.Text)-3);
clientdataset1.CommandText:='select * from t1 where serial_number in ('+mmo1+');
clientdataset1.Open;
label3.Caption:=inttostr(clientdataset1.RecordCount);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
fl:textfile;
sn1:string;
i:integer;
begin
Memo1.Clear;
dlgOpen1.FileName:='';
if dlgopen1.Execute then
begin
assignfile(fl,dlgopen1.FileName);
end;
reset(fl);
while not Eof(fl) do
begin
readln(fl,sn1);
memo1.Lines.Add(QuotedStr(sn1)+',');
end;
closefile(fl);
end; 展开
Form1: TForm1;
mmo1:string;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
SN:string;
begin
begin
if Memo1.Lines.count>1000 then
ShowMessage('警告:查询数不能超过1000')
else
clientdataset1.Close;
mmo1:=copy(memo1.Text,1,Length(Memo1.Text)-3);
clientdataset1.CommandText:='select * from t1 where serial_number in ('+mmo1+');
clientdataset1.Open;
label3.Caption:=inttostr(clientdataset1.RecordCount);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
fl:textfile;
sn1:string;
i:integer;
begin
Memo1.Clear;
dlgOpen1.FileName:='';
if dlgopen1.Execute then
begin
assignfile(fl,dlgopen1.FileName);
end;
reset(fl);
while not Eof(fl) do
begin
readln(fl,sn1);
memo1.Lines.Add(QuotedStr(sn1)+',');
end;
closefile(fl);
end; 展开
展开全部
跟踪一下看看那条语句出的错。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询