Solved

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.

Posted on 2006-11-24
2
146 Views
Last Modified: 2010-04-05
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].FieldName = FieldThen
           Begin
             If Not TQ.Fields.Fields[I].DataType = FieldExpected Then
                Begin
                  Drop := True;
                End
             Else
                Begin
                  Drop := False;
                End
            Break
           End;
      End;
0
Comment
Question by:hidrau
2 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 18006728
replace
             If Not TQ.Fields.Fields[I].DataType = FieldExpected Then
with
             If Not (TQ.Fields.Fields[I].DataType = FieldExpected) Then

0
 
LVL 1

Author Comment

by:hidrau
ID: 18006770
Thks

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now