Hello.
I am using Delphi 2010 to build a small application that builds a very very simple database in CSV file format. I am using the Jcl and JVCL libraries (TJvCSVDataset, TJvDataSource and TJvDBGrid).
I set up the fields ("Last Name", "First Name" and "Email"), where "Email" is the only with the UniqueKey property.
I added a record then I added a second one, putting the same value under "Email". When I post changes to the DB I obviously get a "Key is not unique" error.
I would like to avoid to the user to enter a duplicate e-mail address in the DB. How can I perform this check?
I have also tried to catch the E:EJvCSVKeyError exception but the only result I got is showing a custom message, while the duplicate value is still appearing in the DBGrid. It would be logical that, upon catching that extension, the field value reverts to blank (or to its previous value, if any).

Any idea?

Thank in advance,

Matteo Riso
http://www.zipgenius.it

I dont have use Delphi, but i have 1 idea(idk dose it work in Delphi..)
make 1 procedure and 1 function(or 2 procedures):
function have just huge conts. that haves all emails in it

function email_control(new_email:string)new:boolean;
     const  
         all_emails=['--------------'
                       ,'--------------'
                      ,'--------------'
                             {stop}];
begin
  if new_email in  all_emails then
      new:=false
  else
     new:=true;
end;

and procedure that adds emails in function:

procedure add_new_email(new_email);
var fmain,fhelp:text;
      line:string;
begin
  assign(fmain,email_control.deb);
  assign(fhelp,email_control_help.txt);
  reset(fmain); rewrite(fhelp);
  readln(fmain,line);
  repeat
    writeln(fhelp.line);  
    readln(fmain,line);
    until pos({stop},line')<>0;
  writeln(fhelp, ','+new_mail);
  writeln(fhelp,'{stop}];');
  repeat
    readln(fmain.line);  
    writeln(fhelp,line);
    until eof(fmain);
  close(fhelp);
  rewrite(fmain);reset(fhelp);
  repeat
    readln(fhelp.line);  
    writeln(fmain,line);
    until eof(fhelp);
  close(fmain); 
end;

you can get this pocedure and function to other program with
{$i name of save}
its in pascal but i hope it helps
i hope it helps
one idea more you can make file where are just all mails on diferent lines and make much easyer system(then my 1st idea:sad:), but i keep my work it may halps you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.