第一次执行的时候是正常的,第二次执行的时候,报
project project1.exe raised exception class EOleException with message '[INTERSOLV][ODBC SQL Server driver][SQL Server]ct_command():user'api layer:external error: This routine cannot be called while results are pending for a command that has been sent to the server'. Process stopped.Use Step or Run to continue.
程序如下
begin
ADOStoredProc1.Close;
ADOStoredProc1.ProcedureName:='cjsp_JiXiaoCK_web';
ADOStoredProc1.Parameters.Clear;
with ADOStoredProc1.Parameters.AddParameter do //追加出参数
begin
Name := '@ai_rc';
DataType := ftinteger;
Direction := pdOutput; //out
Size := 20;
end;
with ADOStoredProc1.Parameters.AddParameter do //追加出参数
begin
Name := '@as_msg';
DataType := ftstring;
Direction := pdOutput; //out
Size := 20;
end;
ADOStoredProc1.Prepared:=true;
ADOStoredProc1.Parameters.ParamByName('@ai_rc').Value := 1;
ADOStoredProc1.Parameters.ParamByName('@as_msg').Value :='a';
ADOStoredProc1.ExecProc; 在这里报的错
P1:=ADOStoredProc1.Parameters.ParamByName('@ai_rc').Value; P2:=ADOStoredProc1.Parameters.ParamByName('@as_msg').Value;
ADOStoredProc1.Close; end;
project project1.exe raised exception class EOleException with message '[INTERSOLV][ODBC SQL Server driver][SQL Server]ct_command():user'api layer:external error: This routine cannot be called while results are pending for a command that has been sent to the server'. Process stopped.Use Step or Run to continue.
程序如下
begin
ADOStoredProc1.Close;
ADOStoredProc1.ProcedureName:='cjsp_JiXiaoCK_web';
ADOStoredProc1.Parameters.Clear;
with ADOStoredProc1.Parameters.AddParameter do //追加出参数
begin
Name := '@ai_rc';
DataType := ftinteger;
Direction := pdOutput; //out
Size := 20;
end;
with ADOStoredProc1.Parameters.AddParameter do //追加出参数
begin
Name := '@as_msg';
DataType := ftstring;
Direction := pdOutput; //out
Size := 20;
end;
ADOStoredProc1.Prepared:=true;
ADOStoredProc1.Parameters.ParamByName('@ai_rc').Value := 1;
ADOStoredProc1.Parameters.ParamByName('@as_msg').Value :='a';
ADOStoredProc1.ExecProc; 在这里报的错
P1:=ADOStoredProc1.Parameters.ParamByName('@ai_rc').Value; P2:=ADOStoredProc1.Parameters.ParamByName('@as_msg').Value;
ADOStoredProc1.Close; end;
估計是存儲過程的錯誤.下面是我調用存儲過程的例子:class function TDBFunction.GetSeriesID(aTableName, aIDFieldName: string;
aLength: integer; aCondition: string): string;
begin
Result := '';
if (aTableName = '') or (aIDFieldName = '') then
MessageInfo('參數錯誤!', True);
with GetAADOStoredProc('Sp_GetSeriesID') do
try
Parameters.CreateParameter('@PTableName', ftWideString, pdInput, 20, aTableName);
Parameters.CreateParameter('@PIDFieldName', ftWideString, pdInput, 20, aIDFieldName);
Parameters.CreateParameter('@PLength', ftInteger, pdInput, 0, aLength);
Parameters.CreateParameter('@PCONDITION', ftWideString, pdInput, 100, aCondition);
Parameters.CreateParameter('@PMaxID', ftWideString, pdInputOutput, 10, '');
ExecProc;
Result := Parameters.ParamByName('@PMaxID').Value;
finally
Free;
end;
end;
SQL SERVER中的存储过程如下:
CREATE PROCEDURE Test
@Str VarChar(200),
@Out VarChar(200)='' OutPut
AS
begin tran a
Set @Out='OK'
Select * From Syscolumns where [name]= @Str
if @@Error!=0
begin
rollback tran a
Set @Out='Error'
return
end
commit tran a
GODELPHI中调用如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
with ADOStoredProc1,Parameters do
begin
Close;
ProcedureName := 'Test;1';
Refresh;
ParamByName('@Str').Value := 'ID'; //输入参数
ExecProc;
ShowMessage(ParamByName('@Out').Value); //存储过程输出参数的值
end;
end;
我就不清楚了
我给的是SQL SERVER的
不过你也可以试试看!