Solved

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

Posted on 2007-03-30
2
160 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
A short film showing how OnPage and Connectwise integration works.

930 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

14 Experts available now in Live!

Get 1:1 Help Now