Solved

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

Posted on 2007-03-30
2
163 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
ID: 18826743
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
ID: 18827313
thanks very much
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

790 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