delphi菜鸟求助: 我插入一段sql后出现:'END' expected but 'FINALLY' found 和 EXCEPT or FINALLY expect
functionGetListViewText(mHandle:THandle;mStrings:TStrings;begini:integer):boolean;var...
function GetListViewText(mHandle:THandle; mStrings:TStrings; begini:integer): boolean;
var
vColumnCount,si,bi: Integer;
vItemCount: Integer;
sql: TADOQuery ;
begin
Result := False;
mStrings.BeginUpdate;
try
mStrings.Clear;
begini:=0;
for I:=begini to vItemCount -1 do begin
S:='';
dr:=0;
for J:=0 to vColumnCount -1 do begin
with vItem do begin
iItem:=I;
iSubItem:=J;
end;
if j=0 then
begin
pm:=''+vbuffer;
pmdm:=copy(pm,1,pos(' ',pm)-1);
pm:=copy(pm,pos(' ',pm)+1,100);
--------我在这里插入数据库查询动作如下:------------------------------
begin
sql.Active:=false;
sql.Close;
sql.SQL.Clear;
sql.SQL.Add('select * from p_list where mc like ''%'+trim(list_pm[i])+'%''');
try
sql.Active:=true;
sql.First;
if not sql.Eof then tempdm:=sql.fieldbyname('dm').AsString else tempdm:=ym;
pmdm:=tempdm;
except
writelog(' SQLSTRErr:'+sql.SQL[0]);
end;
--------------以上为我插入语句-----------------------------------------
end;
if j=1 then
begin
rq:=''+vbuffer;
rq:=copy(trim(rq),7,5);
end;
end;
end;
finally // 我插入后这里提示错误[Error] main.pas(283): 'END' expected but 'FINALLY' found
CloseHandle(vProcess);
mStrings.EndUpdate;
end; // 我插入后这里提示错误 [Error] main.pas(287): EXCEPT or FINALLY expected
Result := True;
end; 展开
var
vColumnCount,si,bi: Integer;
vItemCount: Integer;
sql: TADOQuery ;
begin
Result := False;
mStrings.BeginUpdate;
try
mStrings.Clear;
begini:=0;
for I:=begini to vItemCount -1 do begin
S:='';
dr:=0;
for J:=0 to vColumnCount -1 do begin
with vItem do begin
iItem:=I;
iSubItem:=J;
end;
if j=0 then
begin
pm:=''+vbuffer;
pmdm:=copy(pm,1,pos(' ',pm)-1);
pm:=copy(pm,pos(' ',pm)+1,100);
--------我在这里插入数据库查询动作如下:------------------------------
begin
sql.Active:=false;
sql.Close;
sql.SQL.Clear;
sql.SQL.Add('select * from p_list where mc like ''%'+trim(list_pm[i])+'%''');
try
sql.Active:=true;
sql.First;
if not sql.Eof then tempdm:=sql.fieldbyname('dm').AsString else tempdm:=ym;
pmdm:=tempdm;
except
writelog(' SQLSTRErr:'+sql.SQL[0]);
end;
--------------以上为我插入语句-----------------------------------------
end;
if j=1 then
begin
rq:=''+vbuffer;
rq:=copy(trim(rq),7,5);
end;
end;
end;
finally // 我插入后这里提示错误[Error] main.pas(283): 'END' expected but 'FINALLY' found
CloseHandle(vProcess);
mStrings.EndUpdate;
end; // 我插入后这里提示错误 [Error] main.pas(287): EXCEPT or FINALLY expected
Result := True;
end; 展开
1个回答
展开全部
在你代码的第一个try和倒数第二个end之间少一个finally或者except
因为在delphi中try..fially..end或者try..except..end是固定用法。
你粗心大意了。
因为在delphi中try..fially..end或者try..except..end是固定用法。
你粗心大意了。
追问
非常感谢兄台, 但是我只能改,我插入的那段代码, 请问该怎么修改?
追答
给你代码,自己看。
function GetListViewText(mHandle:THandle; mStrings:TStrings; begini:integer): boolean;
var
vColumnCount,si,bi: Integer;
vItemCount: Integer;
sql: TADOQuery ;
begin
Result := False;
mStrings.BeginUpdate;
try
mStrings.Clear;
begini:=0;
for I:=begini to vItemCount -1 do begin
S:='';
dr:=0;
for J:=0 to vColumnCount -1 do begin
with vItem do begin
iItem:=I;
iSubItem:=J;
end;
if j=0 then
begin
pm:=''+vbuffer;
pmdm:=copy(pm,1,pos(' ',pm)-1);
pm:=copy(pm,pos(' ',pm)+1,100);
--------我在这里插入数据库查询动作如下:------------------------------
begin
sql.Active:=false;
sql.Close;
sql.SQL.Clear;
sql.SQL.Add('select * from p_list where mc like ''%'+trim(list_pm[i])+'%''');
try
sql.Active:=true;
sql.First;
if not sql.Eof then tempdm:=sql.fieldbyname('dm').AsString else tempdm:=ym;
pmdm:=tempdm;
except
writelog(' SQLSTRErr:'+sql.SQL[0]);
end;
--------------以上为我插入语句-----------------------------------------
end;
if j=1 then
begin
rq:=''+vbuffer;
rq:=copy(trim(rq),7,5);
end;
end;
end;
end
finally // 我插入后这里提示错误[Error] main.pas(283): 'END' expected but 'FINALLY' found
CloseHandle(vProcess);
mStrings.EndUpdate;
end; // 我插入后这里提示错误 [Error] main.pas(287): EXCEPT or FINALLY expected
Result := True;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询