The function TReportBase. CreateDbProcedure (AReportModule: TReportModule; AProcName: string;
The out ADOStoredProc: TADOStoredProc) : Boolean;
Var
StrList: TStrings;
S, sPar, sMessage, sValue sParameter: string;
I, iIndex: integer;
The begin
Result:=False;
If AProcName="' then the exit;
IIndex:=Pos (' (', AProcName);
If iIndex & gt; 0 then
The begin
SMessage:='began to execute the stored procedure: + AProcName (' +' parameters;
If ADOStoredProc<> Nil then FreeAndnil (ADOStoredProc);
ADOStoredProc:=TADOStoredProc. Create (nil);
StrList:=TStringList. Create;
Try
ADOStoredProc. Connection:=FDataConnect. SqlCnn;
ADOStoredProc. The Parameters. The Clear;
ADOStoredProc.Com mandTimeout:=1200;
ADOStoredProc. ProcedureName:=copy (AProcName, 1, iIndex - 1);
S:=copy (AProcName iIndex + 1, MaxInt);
S:=StringReplace (s') ', ' ', []);
StrToStrings (s, ', ', StrList);
For I:=0 to StrList. Do the Count - 1
The begin
SParameter:=trim (StrList [I]);
If (AReportModule. ConfigDataSet. DataSet<> Nil) and (AReportModule ConfigDataSet. DataSet. FindField (sParameter) & lt;> Nil) then
The begin
AReportModule. ConfigDataSet. DataSet. First;
AReportModule. ConfigDataSet. DataSet. MoveBy (AReportModule. ConfigDataSet. Row);
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 255,
AReportModule. ConfigDataSet. DataSet. FieldbyName (sParameter). AsString) are identical.
SMessage:=sMessage + AReportModule. ConfigDataSet. DataSet. FieldbyName (sParameter). AsString + ', ';
End else if sParameter='StartYear then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 4, AReportModule. Year);
SMessage:=sMessage + AReportModule Year + ', ';
End else if sParameter='Year' then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 4, AReportModule. Year);
SMessage:=sMessage + AReportModule Year + ', ';
The Month end else if sParameter=' 'then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 4, AReportModule. The Month).
SMessage:=sMessage + AReportModule Month + ', ';
End else if sParameter='ProjectCode then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 500, AReportModule. ProjectCode);
SMessage:=sMessage + AReportModule ProjectCode + ', ';
End else if sParameter='TermCode then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 500, AReportModule. TermCode);
SMessage:=sMessage + AReportModule TermCode + ', ';
End else if sParameter='UnitCode then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 500, AReportModule, UnitCode);
SMessage:=sMessage + AReportModule TermCode + ', ';
End else if sParameter='Version' then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 500, AReportModule. Version);
SMessage:=sMessage + AReportModule Version + ', ';
End else if sParameter='YS_SGT_MAIN_FK then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 500, AReportModule. Expand_FK);
SMessage:=sMessage + AReportModule Expand_FK + ', ';
End else if sParameter='Expand_FK then
The begin
ADOStoredProc. The Parameters. CreateParameter (' @ '+ StrList [I], ftString, pdInput, 500, AReportModule. Expand_FK);
SMessage:=sMessage + AReportModule Expand_FK + ', ';
End else if pos ('='sParameter) & gt; 0 then
The begin
SPar:=copy (StrList [I], 1, pos ('='sParameter) - 1);
SValue:=copy (StrList [I], pos ('='sParameter) + 1, MaxInt);
ADOStoredProc. The Parameters. CreateParameter (' @ '+ sPar, ftString, pdInput, 2, sValue);
SMessage:=sMessage + sParameter + ', ';
end;
end;
SMessage:=sMessage + '); ';
If Assigned (FOnProcLogEvent) then
FOnProcLogEvent (Self, sMessage);
Try
ADOStoredProc. ExecProc;
Result:=true;
Except on E: the Exception do
The begin
If Assigned (FOnProcLogEvent) then
FOnProcLogEvent (Self, 'execute the stored procedure error, error stored procedure name "' + AReportModule. ProcName + '" error message' + E.M essage);
FreeAndNil (ADOStoredProc);
Result:=False;
The Exit;
end;
end;
Try
ADOStoredProc. Active:=true;
If ADOStoredProc. RecordCount> 0 then
The begin
FOnProcLogEvent (Self, 'stored procedures successfully returns data set);
End the else
The begin
FOnProcLogEvent (Self, 'stored procedure returns failure data sets);
end;
Except on E: the Exception do
The begin
If Assigned (FOnProcLogEvent) then
FOnProcLogEvent (Self, 'the stored procedure returns no data sets, error message:' + e.M essage);
FreeAndNil (ADOStoredProc);
Result:=False;
The Exit;
end;
end;
The finally
StrList. Free;
end;
end;
end;
What's going on, need to solve, first thanked everybody!