Solved

Duplicate rows in dbgrid

Posted on 2000-04-16
4
479 Views
Last Modified: 2010-04-04
Hello all ...

How does one check if a row to be
added to a dbgrid - already exists - before adding it?

I am not posting any values to the database until I press a certain button ... so all the rows are not yet saved when I want to run this check.

Thanx,
Fats
0
Comment
Question by:ffelaar
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2720293
You can check it directly in your table for example:

if Table1.Locate('Name', Edit1.Text, [loCaseInsensitive]) then
 ...// that means it is already exists

Motaz
0
 

Author Comment

by:ffelaar
ID: 2720335
Wont this way always return false? There really are no records in the dataset yet ... which, by the way, is a tquery selecting from multiple tables and which has cachedupdates enabled.

Fats
0
 
LVL 4

Accepted Solution

by:
Radler earned 50 total points
ID: 2727357
procedure AddField( AField : TField );
for i:=0 to grid.Columns.Items-1 do begin
  grid.Columns.Items[i].FieldName = Afield.FieldName then begin
    //Skip add action
  end else begin
   //Add the field
  end;
end;

T++, Radler
0
 

Author Comment

by:ffelaar
ID: 2792112
I have used a variation of your comment. It put me in the right direction.

Thank you Radler
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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