Code: Select all
SELECT COLUMN_NAME AS name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE OBJECTPROPERTY(OBJECT_ID(CONSTRAINT_SCHEMA + '.' + CONSTRAINT_NAME), 'IsPrimaryKey') = 1 AND TABLE_NAME = 'TBNAME' AND TABLE_SCHEMA = 'dbo'
Code: Select all
function v_FetchQueryPrimaryKey(A_Query: TSQLQuery; A_TableName: string): string;
var
LColumnDS: TSQLQuery;
LColumnField: TField;
begin
Result := '';
if A_TableName = '' then Exit;
LColumnDS:= TSQLQuery.Create(A_Query);
LColumnDS.SQLConnection := A_Query.SQLConnection;
try
LColumnDS.SQL.Text :=
Format('SELECT COLUMN_NAME AS name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE OBJECTPROPERTY(OBJECT_ID(CONSTRAINT_SCHEMA + ''.'' + CONSTRAINT_NAME), ''IsPrimaryKey'') = 1 '
+'AND TABLE_NAME = ''%s'' AND TABLE_SCHEMA = ''dbo'' ', [A_TableName]);
LColumnDS.Open;
LColumnField := LColumnDS.Fields[0];
while not LColumnDS.Eof do
begin
if A_Query.FindField(LColumnField.AsString) <> nil then begin
Result := Result + UpperCase(LColumnField.AsString);
if LColumnDS.RecNo <> LColumnDS.Recordcount then // <- NOTE LColumnDS.Recordcount!
Result := Result + ',';
end;
LColumnDS.Next();
end;
Finally
FreeAndNil(LColumnDS);
end;
end;
I got the error message:"Operation Not Supported" in ISAPI mode.
Keep following the "GetQuoteChar" source code, it seems to come from the MetaData driver, the Devart DBX Driver.
Any ideas on whether this is a bug or not and if so where?
My environment:
- Windows 10 and Windows Server 2012 IIS
- SQL Server 2014
- Delphi XE7
- dbexpress for SQL Server 9.0.1 and used DevartSQLServerDirectBuiltin mode.