delphi报错

ou630j 2008-12-02 04:26:32
var i,j:integer;
mmsqls,mtsqls:string;
ttsqls:string;
// mmfilegroup:string;
mmvariant:string;
a,b:string;
strfile,strvalue:string;
begin
try
mmsqls:='select * from _syscopyschemejob where schemeid ='+ quotedstr(self.replid );
with self.DQuery do
begin
close;
sql.Clear;
sql.Add(mmsqls);
open;
end;

if self.DQuery.isempty then exit;
mmfilegroup:=self.DQuery.Fieldbyname('fieldgroup').AsString ; mmvariant:=self.DQuery.Fieldbyname('schemevariant').AsString ;
mtsqls:='select max(id) as seq from _sysCopyschemeVariant where fieldgroup='+quotedstr(mmfilegroup);
with self.DQuery do
begin
close;
sql.Clear;
sql.Add(mtsqls);
open;
end;
j:=self.DQuery.Fieldbyname('seq').AsInteger ;
if j<=0 then exit;
for i:=1 to j do
begin
mtsqls:='select * from _sysCopyschemeVariant where fieldgroup='+quotedstr(mmfilegroup)+'and id='+inttostr(i);
with self.DQuery do
begin
close;
sql.Clear;
sql.Add(mtsqls);
open; //fieldvalue fieldid
end;
a:=self.DQuery.Fieldbyname('fieldid').AsString ;
b:=self.DQuery.Fieldbyname('fieldvalue').AsString ;
if i=1 then
begin
strfile:=a;
strvalue:=b;
end
else
begin
strfile:=strfile+','+ a;
strvalue:= strvalue+','+ b;
end;
end;
finally
Freeandnil(self.DQuery) ;
end;
end;
Procedure TDBCopyScheme.Getshinitwhere() ; //得到来源表条件里面的值。
var
mySQls,filed:string;
A:ANSIString;
i:integer;
Str:TStringList;
shu:string;
begin
Str := TStringList.Create ;
try
str.Delimiter := '&';
str.DelimitedText:=bianwhere;
for i :=0 to Str.Count do
begin
if eco3funlib.FindStr(strfile,'Str.Strings[i]',false) then exit;
shu:=eco3funlib.GetRefFieldbySelfField(strfile,strvalue,'Str.Strings[i]',',');
bianwhere:= replacestr(bianwhere,'&'+Str.Strings[i]+'&',shu,false) ;--出错
end;
finally
end;
end;

报错
---------------------------
Debugger Exception Notification
---------------------------
Project iBaanC4.exe raised exception class EStringListError with message 'List index out of bounds (3)'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
...全文
98 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ou630j 2008-12-09
  • 打赏
  • 举报
回复
解决了,是释放变量的问题
taste品味 2008-12-03
  • 打赏
  • 举报
回复
截获SQL语句,用查询分析器执行就知道错误了
eqapple 2008-12-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 Corn1 的回复:]
最后一段,
for i :=0 to Str.Count do
改成:
for i :=0 to Str.Count - 1 do
[/Quote]
按照这个改一下。
如果在报错,只能程序其他地方还有错误。在继续跟踪。
像楼上说的,楼主应当在调试在上下功夫。
ahjoe 2008-12-02
  • 打赏
  • 举报
回复
要学会跟踪。
yangkunjie 2008-12-02
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 ou630j 的回复:]
断点进去N次,

分数少?怎么没有人答,加分啊,我加分,解答出来加20分
[/Quote]
无语

从提示上看是索引越界
看你断点错误的地方,估计是bianwhere赋值的问题,最后赋给它的值应该不是你想要的
想办法把bianwhere这个变量打印出来看看
ou630j 2008-12-02
  • 打赏
  • 举报
回复
断点进去N次,

分数少?怎么没有人答,加分啊,我加分,解答出来加20分
panrongzeng 2008-12-02
  • 打赏
  • 举报
回复
replacestr断点进去这个函数看看哪里错误了
ou630j 2008-12-02
  • 打赏
  • 举报
回复
没有用的,我原来就是for i :=0 to Str.Count - 1 do这个
然后就改为for i :=0 to Str.Count do
Corn1 2008-12-02
  • 打赏
  • 举报
回复
最后一段,
for i :=0 to Str.Count do
改成:
for i :=0 to Str.Count - 1 do
ou630j 2008-12-02
  • 打赏
  • 举报
回复
后面那里写了出错
bianwhere:= replacestr(bianwhere,'&'+Str.Strings[i]+'&',shu,false) ;--出错
这个bianwhere的意思是一个公共变量,我用它代替一个字符如where后面的条件
比如bianwhere:=run='&run&' and yun='&yun&'
panrongzeng 2008-12-02
  • 打赏
  • 举报
回复
出现错误后指向哪个代码?

5,391

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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