delphi 用FireDAC获取 SQL SERVER错误文本信息


本文整理自网络,侵删。

 
SQL SERVER获取错误文本信息,BDE、adoquery一直取不到,FDQuery可以了

Some DBMS, like SQL Server, return messages as an additional result set. So, to process messages, the application needs to process multiple result sets. Here is a more complex example, providing status and messages for SQL Server. As you see, we are using TFDMemTable to store result sets with rows.

var
  i: Integer;
begin
  FDConnection1.ResourceOptions.ServerOutput := True;
  FDQuery1.FetchOptions.AutoClose := False;
  FDQuery1.Open('select * from Region; print ''Hello''');
  FDMemTable1.Data := FDQuery1.Data;
  Memo1.Lines.Add(Format('%d rows processed', [FDMemTable1.RecordCount]));
  FDQuery1.NextRecordSet;
  if FDConnection1.Messages <> nil then
    for i := 0 to FDConnection1.Messages.ErrorCount - 1 do
      Memo1.Lines.Add(FDConnection1.Messages[i].Message);
end;

相关阅读 >>

Delphi 从 twebbrowser中获得当前输入处的链接

Delphi adoquery filter使用

Delphi2010中Delphi class explorer妙用

Delphi xe2 - 点点滴滴

Delphi 实现程序放放多个进程条

Delphi 在tunimemo中复制和粘贴选定的文本

Delphi 调用外部程序获取程序id,并能关闭该程序

Delphi winapi: movewindow - 改变窗口的位置与大小

Delphi中messagebox的用法

Delphi 读写文本文件

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...