Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EdatabaseError problems

Status
Not open for further replies.

domkop

Programmer
Aug 19, 2003
22
NL
i never worked with databases before so now i got the problem that i have a required field that if i leave it empty raises the error: edatabase error field must have a value.
how do i have to deal with this error??
what am i doing wrong

procedure Tnamenoverzicht.bewaarClick(Sender: TObject);
//bewaar knop
begin
try
namen.Post;
except
on EDatabaseError do
MessageDlg('field is empty', mtwarning,[mbok], 0) ;
 
I would validate that the field is not empty BEFORE you post. Something like this:
Code:
procedure Tnamenoverzicht.bewaarClick(Sender: TObject);
//bewaar knop
begin
  if table.fieldByName('KeyField').IsNull then
  begin
    ShowMessage('KeyField cannot be blank.');
    Edit1.SetFocus;  //put the cursor in the field that can't be blank...
  end
  else
    namen.Post;
end;
-Dell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top