TSQLTimeStamp Validation Issue

TSQLTimeStamp Validation Issue

Postby mmalinow » Wed 01 Aug 2012 15:39

Hello,

Hoping you can give some feedback. Using dbexpoda40.dll with Delphi 2010.
On exiting a DBEdit whose field type is a TSQLTimeStampField when an invalid date is entered, I receive the exception "Could not parse SQL TimeStamp String". I am attempting to intercept this exception to give the user a more specific message. Do you have any suggestions as to an approach?

Thank you,
Mike Malinowski
PRG
mmalinow
 
Posts: 24
Joined: Sat 14 May 2011 00:56

Re: TSQLTimeStamp Validation Issue

Postby AlexP » Thu 02 Aug 2012 09:48

hello,

To intercept this error, you can use the SetText event of this field, or validate the inserted data by yourself using the TryStrToSqlTimeStamp method:
Code: Select all
procedure TForm1.ClientDataSet1F_TIMESTAMPSetText(Sender: TField;
  const Text: string);
var
  Value: TSQLTimeStamp;
begin
  if TryStrToSqlTimeStamp(Text, Value) then
    TSQLTimeStampField(Sender).SetData(@Value, False)
  else
    ShowMessage('Error');}
end;

or intercept this error:
Code: Select all
procedure TForm1.ClientDataSet1F_TIMESTAMPSetText(Sender: TField;
  const Text: string);
begin
  try
    TSQLTimeStampField(Sender).AsString :=  Text;
  except
    on e: EConvertError do
      ShowMessage(e.Message);
  end;
end;
AlexP
Devart Team
 
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TSQLTimeStamp Validation Issue

Postby mmalinow » Thu 02 Aug 2012 12:06

Hello,

Have not implemented yet.
Just wanted to thank you for your reply.

Mike Malinowski
mmalinow
 
Posts: 24
Joined: Sat 14 May 2011 00:56


Return to dbExpress driver for Oracle