Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
147 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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