用TADOStoredProc运行存储过程,第一次运行正常,当再次运行这个函数时就出错,提示参数过多?
function TfrmLogin.AddLinkServer: boolean;
var
ReVal: integer;
begin
result := true;
with astpUpdate do//调用存储过程
begin
try
self.cursor:=crHourGlass;
Active := false;
ProcedureName := 'UpdAddLinkServer';
CommandTimeout := aConnLocal.CommandCount;
with Parameters.AddParameter do
begin
Name := '@StrHost';
Datatype := ftString ;
Direction := pdInput;
Value := Trim(edtRemoteHost.Text);
end;
with Parameters.AddParameter do
begin
Name := '@StrAccount';
Datatype := ftString;
Direction := pdInput;
Value := Trim(edtRemoteAccount.Text);
end;
with Parameters.AddParameter do
begin
Name := '@StrPass';
Datatype := ftString;
Direction := pdInput;
Value := Trim(edtRemotePass.Text);
end;
with Parameters.AddParameter do
begin
Name := '@ReVal';
Datatype := ftInteger;
Direction := pdInputOutput;
end;
lblState.Caption := '正在建立远程数据库连接!';
lblState.Visible := true;
Prepared := true;
ExecProc;
ReVal := Parameters.ParamByName('@ReVal').Value;
//这是这一行,提示参数过多
IF ReVal = 1 then
begin
lblState.Caption := '已经建立与远程数据库连接!';
close;
end
else
BEGIN
lblState.Caption := '建立远程数据库连接失败,请检查输入的信息!';
self.Cursor := crDefault;
MessageDlg('建立远程数据库连接失败,请检查输入的信息!',mtWarning,[mbOk],0);
close;
result := false;
END;
self.Cursor := crDefault;
except
lblState.Caption := '建立远程数据库连接失败,请检查输入的信息!';
self.Cursor := crDefault;
MessageDlg('建立远程数据库连接失败,请检查输入的信息!',mtWarning,[mbOk],0);
close;
end;//try
end;//存储过程
end;