Page 1 of 1

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

Posted: Wed 15 Jun 2016 13:53
by dupe
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;

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

Posted: Thu 16 Jun 2016 09:53
by ViktorV
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.