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 结构体的使用、tbitmap和tmemorystream的转换

Delphi listbox自动获取列表框中的组件焦点

Delphi 获取北京时间

Delphi 判断 中文字符

Delphi 如何在richedit控件里加入链接

Delphi 为当前窗口客户区捉图: getformimage

Delphi 中相对路径与绝对路径函数说明

Delphi xe5 给edit增加自定义按钮

Delphi 通过twebbrowser文档中的id查找html元素

Delphi 实现软件版验证码

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



打赏

取消

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

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

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

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

评论

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

    暂无评论...