我自己写了一个函数,我还是第一次写函数,各位高手请指教!

thebest123 2003-08-20 04:13:08
procedure SetCmbDict2(myComBox: TComboBox; iDictEntry :integer;iDictEntry2 :integer);
var
MyQuery :TAdoQuery;
SQLCode,StrTemp: string;
i: integer;
begin
try
MyQuery:= TadoQuery.Create(nil);
try
with MyQuery do
begin
Connection := Adocon;
if Active then Close;
SQL.Clear;
SQLCode := ' set rowcount 0 select subentry,dict_entry, dict_prompt'
+ ' from run..dictionary '
+ ' where dict_entry = ' + IntTostr(iDictEntry)
+ ' or dict_entry = ' + IntTostr(iDictEntry2)
+ ' and subentry != -1 '
+ ' and access_level != 3 '
+ ' order by subentry';
SQL.Add(SQLCode);
Open;
if not MyQuery.IsEmpty then
begin
with myComBox do
begin
Items.Clear;
for i := 0 to MyQuery.RecordCount - 1 do
begin
strTemp := FieldByName('dict_entry').Asstring + '.' + FieldByName('subentry').Asstring + '.' + FieldByName('dict_prompt').AsString;
myComBox.Items.Add(strTemp);
myComBox.ItemIndex :=0;
MyQuery.Next;
end;
end;
end;
end;
except
MyQuery.Free;
end;
finally
MyQuery.Free;
end;
end;
请各位高手帮我看看错在那里?
...全文
37 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
IwantFlay 2003-08-20
  • 打赏
  • 举报
回复
你的setCmbDict2是在哪个窗体中的?
procedure 窗体名.SetCmbDict2(myComBox: TComboBox; iDictEntry :integer;iDictEntry2 :integer);
你地过程中引用了一个窗体中的adoconn吧. 如果想写一个单独的过程,干脆连adoConn也传进来吧.
wzf54 2003-08-20
  • 打赏
  • 举报
回复
要判断SQL语句有没有问题,可以在OPen之前加Memo1.lines.add(sql.code); exit;
语句,然后执行,把Memo1在的文本复制到可以执得SQL语句的工具中,问题就很容易解决了
thebest123 2003-08-20
  • 打赏
  • 举报
回复
IORILI(近视眼@_@) 谢谢,我问题解决了!呵呵!各位太感谢你们了!
thebest123 2003-08-20
  • 打赏
  • 举报
回复
没有人肯帮忙吗?有没有好心人在呀?!帮帮我拉,谢谢
gzyzljk 2003-08-20
  • 打赏
  • 举报
回复
未定义标识:SetCmbDict2
IORILI 2003-08-20
  • 打赏
  • 举报
回复
没有声明
procedure SetCmbDict2(myComBox: TComboBox; iDictEntry :integer;iDictEntry2 :integer);
在有procedure的地方 或 private
{ Private declarations }或
public 后
加上
thebest123 2003-08-20
  • 打赏
  • 举报
回复
我编译的时候提示错误是这样的:[Error] LawSearchTotal.pas(174): Undeclared identifier: 'SetCmbDict2'
thebest123 2003-08-20
  • 打赏
  • 举报
回复
我已经试过了不行
有谁可以帮我看看SQL语句部分有没有错!
charles2118 2003-08-20
  • 打赏
  • 举报
回复
except处应该假
on e:EDatabaseError do
begin
if Application.MessageBOx('操作发生错误,是否显示错误信息?', '发生错误', mb_YesNo + mb_IconInformation ) = mrYes then
Application.MessageBox( PChar(e.Message), '错误信息', mb_Ok + mb_IconInformation );
Result:=false;
exit;
end;
thebest123 2003-08-20
  • 打赏
  • 举报
回复
呵呵,谢谢
是不是函数,而是过程
那位高手帮我看看在那里出问题了,我调用的时候不行
charles2118 2003-08-20
  • 打赏
  • 举报
回复
呵呵,这个不是函数,是进程,概念不同的!

5,379

社区成员

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

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