hidrau
asked on
I need to create a function that will drop a field from a table, but I am having problem to create this function due to the kind of the field.
The error is when I try to compare whether the DataType is equal FieldExpected.
Function (Table, Field : String; FieldExpected: TFieldType) : Boolean
Var
TQ : TADOQuery;
I : Integer;
Drop : Boolean;
Begin
TQ := TADOQuery.Create(Nil);
TQ.Connection := Fmenu.ADOConnection1;
Drop := False;
Try
With TQ do
Begin
Close;
Sql.Add('SELECT * FROM ' + Table);
Open;
For I := 0 to Pred(TQ.Fields.Count) do
Begin
If TQ.Fields.Fields[I].FieldN ame = FieldThen
Begin
If Not TQ.Fields.Fields[I].DataTy pe = FieldExpected Then
Begin
Drop := True;
End
Else
Begin
Drop := False;
End
Break
End;
End;
Function (Table, Field : String; FieldExpected: TFieldType) : Boolean
Var
TQ : TADOQuery;
I : Integer;
Drop : Boolean;
Begin
TQ := TADOQuery.Create(Nil);
TQ.Connection := Fmenu.ADOConnection1;
Drop := False;
Try
With TQ do
Begin
Close;
Sql.Add('SELECT * FROM ' + Table);
Open;
For I := 0 to Pred(TQ.Fields.Count) do
Begin
If TQ.Fields.Fields[I].FieldN
Begin
If Not TQ.Fields.Fields[I].DataTy
Begin
Drop := True;
End
Else
Begin
Drop := False;
End
Break
End;
End;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER