unit StoredProceduresMain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uDADriverManager, uDAClasses, StdCtrls, uDAInterfaces, uDAEngine, uDAADODriver, Grids, uDAIBXDriver, Spin; type TStoredProceduresMainForm = class(TForm) DADriverManager: TDADriverManager; ExecuteButton: TButton; DAADODriver1: TDAADODriver; Label1: TLabel; cbConnName: TComboBox; Label2: TLabel; cbSPNames: TComboBox; ConnectButton: TButton; ListParamsButton: TButton; StringGrid: TStringGrid; DAIBXDriver1: TDAIBXDriver; SpinEdit: TSpinEdit; Label3: TLabel; DAConnectionManager: TDAConnectionManager; DASchema: TDASchema; procedure ExecuteButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ConnectButtonClick(Sender: TObject); procedure ListParamsButtonClick(Sender: TObject); procedure FormDestroy(Sender: TObject); private fConn : IDAConnection; procedure CheckConnection; public end; var StoredProceduresMainForm: TStoredProceduresMainForm; implementation uses uROClasses, TypInfo; {$R *.dfm} procedure TStoredProceduresMainForm.CheckConnection; begin Check(fConn=NIL, 'Connect to a database first!'); end; procedure TStoredProceduresMainForm.ExecuteButtonClick(Sender: TObject); var cmd : IDASQLCommand; x, i : integer; begin CheckConnection; cmd := fConn.NewCommand(cbSPNames.Text, stStoredProcedure); cmd.RefreshParams; for x := 1 to SpinEdit.Value do begin for i := 0 to cmd.Params.Count-1 do if (StringGrid.Cells[4, i+1]<>'') then cmd.ParamByName(StringGrid.Cells[0, i+1]).AsString := StringGrid.Cells[4, i+1]; cmd.Execute; for i := 0 to cmd.Params.Count-1 do StringGrid.Cells[4, i+1] := cmd.ParamByName(StringGrid.Cells[0, i+1]).AsString; end; end; procedure TStoredProceduresMainForm.FormCreate(Sender: TObject); var i : integer; begin for i := 0 to DAConnectionManager.Connections.Count-1 do cbConnName.Items.Add(DAConnectionManager.Connections[i].Name); cbConnName.ItemIndex := 0; end; procedure TStoredProceduresMainForm.ConnectButtonClick(Sender: TObject); var i : integer; names : IROStrings; begin fConn := DAConnectionManager.NewConnection(cbConnName.Text); cbSPNames.Items.Clear; names := NewROStrings; fConn.GetStoredProcedureNames(names); for i := 0 to (names.Count-1) do cbSPNames.Items.Add(names[i]); cbSPNames.ItemIndex := 0; cbSPNames.DroppedDown := TRUE; ListParamsButton.Enabled := cbSPNames.Items.Count>0 end; procedure TStoredProceduresMainForm.ListParamsButtonClick(Sender: TObject); var i : integer; cmd : IDASQLCommand; par : TDAParam; begin CheckConnection; cmd := fConn.NewCommand(cbSPNames.Text, stStoredProcedure); cmd.RefreshParams; StringGrid.RowCount := cmd.Params.Count+1; if (StringGrid.RowCount>1) then StringGrid.FixedRows := 1; StringGrid.FixedCols := 4; StringGrid.Cells[0, 0] := 'Name'; StringGrid.Cells[1, 0] := 'Type'; StringGrid.Cells[2, 0] := 'Size'; StringGrid.Cells[3, 0] := 'Direction'; StringGrid.Cells[4, 0] := 'Value'; for i := 0 to (cmd.Params.Count-1) do begin par := cmd.Params[i]; StringGrid.Cells[0, i+1] := par.Name; StringGrid.Cells[1, i+1] := GetEnumName(TypeInfo(TDADataType), Ord(par.DataType)); StringGrid.Cells[2, i+1] := IntToStr(par.Size); StringGrid.Cells[3, i+1] := GetEnumName(TypeInfo(TDAParamType), Ord(par.ParamType)); StringGrid.Cells[4, i+1] := ''; end; end; procedure TStoredProceduresMainForm.FormDestroy(Sender: TObject); begin fConn := nil; end; end.