procedure TForm9.ConnInfoMessage(Connection: TADOConnection; const Error: Error; var EventStatus: TEventStatus); var I:Integer; begin Memo1.Lines.Add('Count: '+IntToStr(Connection.Errors.Count)); for I:=0 to Connection.Errors.Count-1 do Memo1.Lines.Add(Connection.Errors[I].Description); end;
Error只有一个值,Connection.Errors.Count 也等于 1
----------------------------------------------
SQL SERVER DBA QQ:315054403 曾经的Delphier 缘在上海
type TForm1 = class(TForm) RichEdit1: TRichEdit; FDConnection1: TFDConnection; FDPhysMSSQLDriverLink1: TFDPhysMSSQLDriverLink; FDStoredProc1: TFDStoredProc; procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin FDConnection1.ResourceOptions.ServerOutput := True;; end;
procedure TForm1.FormShow(Sender: TObject); var I: Integer; begin FDStoredProc1.StoredProcName := 'TestProc'; FDStoredProc1.ExecProc; for I := 0 to FDConnection1.ConnectionIntf.Messages.ErrorCount - 1 do RichEdit1.Lines.Add(FDConnection1.ConnectionIntf.Messages[i].Message); end;
感谢 bluestorm8 大侠出手,SDAC是三方控件,所以试了FireDAC: QTmp.SQL.Clear; QTmp.SQL.Add('print ''aa''; print ''bb''; print ''cc''; print ''dd'';'); QTmp.SQL.Add('select top 5 name into #t from sys.tables;'); QTmp.SQL.Add('select top 8 name into #t2 from sys.tables;'); QTmp.ExecSQL; for I := 0 to Conn.ConnectionIntf.Messages.ErrorCount-1 do Memo2.Lines.Add(Conn.ConnectionIntf.Messages.Errors[I].Message);
print 的消息可以取到。。但受影响的行没取到,也没找到什么相关属性可调整
----------------------------------------------
SQL SERVER DBA QQ:315054403 曾经的Delphier 缘在上海