本人在一表单中因多次使用下列语句:
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoquery1.Open;
因此编了一个过程如下:
//在程序开端声明
var
procedure proc1();
……
procedure proc1();
begin
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoquery1.Open;
end;
在调用时,总是出错:Undeclared identifier: 'adoquery1'
'(' expected but ';' found
如果不调用,将以上语句放回原处,则没有问题。
好像程序一运行就执行proc1()过程,即在设置adoquery1数据前。
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoquery1.Open;
因此编了一个过程如下:
//在程序开端声明
var
procedure proc1();
……
procedure proc1();
begin
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoquery1.Open;
end;
在调用时,总是出错:Undeclared identifier: 'adoquery1'
'(' expected but ';' found
如果不调用,将以上语句放回原处,则没有问题。
好像程序一运行就执行proc1()过程,即在设置adoquery1数据前。
解决方案 »
- 请教高手:关于mmtools的问题
- Load from Structured Storage in memory without temporaray files on disk
- 武汉的delphi fans们,我来此宝地招人,为了delphi,多捧场啊 :-)
- 如何解决PageContral切换各Tab时的界面闪烁问题,因为各Tab的元素跟控件各不相同且数量不少。
- 在 delphi可如何注册OCX控件呀?
- 请问如何在Panel控件上画线?
- 请教两个三角以上或星星的
- 怎么来实现像NetMeeting一样传文件的功能?分还会另外给的!UP有分
- 简单问题,急!!!!
- 请问现在为了delphi而学parscl有前途有意义吗,都说C++有闪途有前途
- 请问delphi 2007能跟delphi 7同时安装么?
- 已在Excel中做好固定模版,如何将此模板存放在Access中以方便数据导出?
1.一个办法如上楼上所说
2.将这个方法,移植到你的窗体中取。
方法体:function proc1(adoq:TAdoquery):integer;
begin
adoq.Close;
adoq.SQL.clear;
adoq.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoq.Open;
result 1;
end
调用:proc1(adoquery1);
方法体:function proc1(adoq:TAdoquery):integer;
begin
adoq.Close;
adoq.SQL.clear;
adoq.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoq.Open;
result 1;
end
调用:proc1(adoquery1);
procedure proc1(); //只需将此句话改为procedure tform.proc1(); 即可。
begin
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoquery1.Open;
end;
现给分
Private或者Public中声明
比如:
Private
procedure proc1(); //写完后按 Shift+Ctrl+C键,在实现部分生成函数体implementationprocedure TForm1.proc1(); //假设在Form1里
begin
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from xggn where xggnfl=''ckdd''');
adoquery1.Open;
end;如果一定要定义成全局的可以
fucntion TForm1.proc1(Query:TAdoQuery;SqlStr):Boolean;
begin
Result:=false;
if Query=nil then exit;
with Query do
begin
try
Close;
SQL.Text:=SqlStr;
Open;
Result:=true;
except
end;
end;
end;