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;
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步