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
144 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:
ciuly 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

11 Experts available now in Live!

Get 1:1 Help Now