Solved

Duplicate rows in dbgrid

Posted on 2000-04-16
4
455 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I have used a variation of your comment. It put me in the right direction.

Thank you Radler
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

17 Experts available now in Live!

Get 1:1 Help Now