Solved

Duplicate rows in dbgrid

Posted on 2000-04-16
4
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 81
TServerSocket - file via sendbuf or Text via sendtext ? 1 76
enhance the following code 3 42
Delphi android app hide keyboard 3 47
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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