SQL Server Error 11509: "The metadata could not be determined ...", when preparing different SELECT-Statements

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dupe
Posts: 21
Joined: Wed 15 Jun 2016 13:37

SQL Server Error 11509: "The metadata could not be determined ...", when preparing different SELECT-Statements

Post by dupe » Wed 15 Jun 2016 13:53

Hi,

i get the SQL Server Error 11509 when preparing a SQL Statement with two different SELECT instructions.
How can i avoid this error?

For demonstration i prepared a simple example.

Code: Select all

var
  q: TMSQuery;
begin
  q := TMSQuery.Create(nil);
  try
    q.Connection := StdManDataBase;
    q.SQL.BeginUpdate();
    q.SQL.Add('IF 1 = 1');
    q.SQL.Add('SELECT 1, 2');
    q.SQL.Add('ELSE');
    q.SQL.Add('SELECT 1');
    q.SQL.EndUpdate();
    q.Prepare; // SQL Server Error 11509
  finally
    q.Free;
  end;

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: SQL Server Error 11509: "The metadata could not be determined ...", when preparing different SELECT-Statements

Post by ViktorV » Thu 16 Jun 2016 09:53

This error is generated by NativeClient, and we can't affect this. You can avoid this behavior using the standard OLEDB Provider or Direct mode. For this, set the TMSConnection.Options.Provider property to prSQL or prDirect respectively.

Post Reply