Solved

How can I identify a kind of field from my access table?

Posted on 2007-03-30
2
158 Views
Last Modified: 2013-11-23
Hello Guys,

I have a system to update access database, I make a backup from my rows in a file and after updating the
access dabase I restore my rows. Some tables I have a autonumber  field, I don't use them, but I have a problem with my procedure because it tries to recored the number in this field. How could I identify if my field is a autonumber field, so I could skip this field in my while. Take a look at my code:
    Qry.Close;
    Qry.Sql.Clear;
    Qry.Sql.Add('SELECT * FROM ' + Tabela);
    Qry.Open;
    Qrestore.LoadFromFile(MyFile);

     While Not Qrestore.Eof do
      Begin
          Qry.Append;
          For I := 0 to Pred(Qrestore.FieldCount) do
          Begin
            Qry.FieldByName(Qrestore.Fields.Fields[I].FieldName).AsString := Qrestore.Fields.Fields[I].AsString
          End;
          Qry.Post;
          Application.ProcessMessages;
          Gauge1.Progress := Gauge1.Progress + 1;
          Qrestore.Next;
        End;
0
Comment
Question by:hidrau
2 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
Comment Utility
Try this

if not (Qry.FieldByName(Qrestore.Fields.Fields[I].FieldName) is TAutoIncField) then
      Qry.FieldByName(Qrestore.Fields.Fields[I].FieldName).AsString := Qrestore.Fields.Fields[I].AsString
0
 
LVL 1

Author Comment

by:hidrau
Comment Utility
thanks very much
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

744 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

17 Experts available now in Live!

Get 1:1 Help Now