Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

774 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