My table Customers has a field UserID which is indexed.

Now when I am dropping this Field from delphi, I am getting EOleExecption as its a indexed field.
I tried with following code:
ObjCustomers := TADOTable.Create(nil);
ObjCustomers.Connection := Connection;
ObjCustomers.TableName := 'Customers';
ObjCustomers.Open;
if (ObjCustomers.FindField('UserID').IsIndexField) then
begin
ExecuteSQLStatements(['DROP INDEX UserID ON Customers']);
end;
But this Tfield.IsIndexField is coming up False for this case.
Further I dont wanna do something like this:
try
ExecuteSQLStatements(['DROP INDEX UserID ON Customers']);
except
on E: exception do
end;
Is there any way so that I can check whether the field is Indexed, before executing SQL query?
Thankx in advance!
GetIsIndexFieldis not implemented byTADODataSet, and the result will beFalse.Use
TADOConnection.OpenSchemato retrieves table indexes:To make this answer complete:
As suggested by TLama you can use the
TADODataSetmethodGetIndexNames.ADOis internally usingCommand.ActiveConnection.OpenSchema(adSchemaIndexes...