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
148 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
[X]
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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…

749 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