SQL OOP问题:输出中实际参数太多 [英] SQL OOP problem : Too many actual parameters on output

查看:73
本文介绍了SQL OOP问题:输出中实际参数太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请提供以下帮助:

错误:调用类过程行上的实际参数过多.

ERROR : too many actual parameters on calling class procedure line.

主要单位:

procedure TForm1.btnbtbtn1Click(Sender: TObject);
var
  bwagwoord,bemail :boolean ;
  epos,wagwoord,safvoer :String ;
begin
  Form2.qryreg.Close;
  form2.qryreg.SQL.Text := 'select * from registertb ';
form2.qryreg.open ;

epos := edt1.text ;
wagwoord := edt2.text ;
safvoer := ' ';
bemail :=form2.qryreg.locate ('Email',epos,[]);
bwagwoord := form2.qryreg.Locate('Wagwoord',wagwoord,[]);


Login.create(epos,wagwoord,bepos,bwagwoord);
Login.toetslog(safvoer);
showmessage(safvoer);
end;

CLASS:

unit cls_login;

interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls, Buttons, math, ExtCtrls;
type
Tlogin = class(Tobject)

private

Fepos :string ;
fwagwoord :string ;
Fbepos : Boolean;
fbwagwoord : Boolean;


Constructor Create(epos,wagwoord:String;bepos, bwagwoord: boolean);
procedure toetslog(var safvoer :string );
public
end;
implementation

{ Tlogin }
constructor Tlogin.Create(epos, wagwoord: String;bepos, bwagwoord: boolean);
begin
fepos := epos ;
fwagwoord := wagwoord ;
fbepos := bepos;
fbwagwoord := bwagwoord;
end;
procedure Tlogin.toetslog( var safvoer :String );
begin

if (fbepos = True) and (fbwagwoord = True)
then
begin
safvoer := 'Welcome '+' '+fepos
 end
else
safvoer := 'SORRY VERKEERD HEHE'+' '+fwagwoord ;
end;

end.    

推荐答案

好的,我一直在浏览格式不正确的代码,我想我发现了问题所在.但是,您的问题并不容易:正如我所说,您的代码显示格式不正确,并且错误消息也可能是错误的.如果对代码进行了格式化,并且按字面意思报告了错误,则问题将非常明显.

OK, I have been wading through your poorly formatted code, and I think I found the problem. Your question did not make it easy, though: as I said, your code shows poor formatting and the error message is probably wrong too. If the code had been formatted, and the error reported literally, the problem would have been rather obvious.

您的构造函数TLogin.Create()和方法TLogin.toetslog() 都是私有的.如果尝试从另一个设备呼叫它们,则将无法访问它们.因此,从主机单元来看,唯一有效的构造函数是不带参数的创建.如果调用带参数的创建,则会收到错误"Too many parameters on call to..."或类似错误.

Your constructor TLogin.Create() and your method TLogin.toetslog() are both private. If you try to call them from another unit, they are not accessible. So, from the main unit, the only valid constructor is Create without parameters. If you call Create with parameters, then you will get the error "Too many parameters on call to..." or similar.

这样做:

type
  TLogin = class(TObject)
  private
    Fepos: string;
    Fwagwoord: string ;
    Fbepos: Boolean;
    Fbwagwoord: Boolean;
  public
    constructor Create(epos, wagwoord: string; bepos, bwagwoord: Boolean);
    procedure ToetsLog(var safvoer: string);
  end;

并以这种方式调用构造函数:

And call the constructor this way:

  Login := TLogin.Create(epos, wagwoord, bepos, bwagwoord);

这篇关于SQL OOP问题:输出中实际参数太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆