TSQLTimeStamp Validation Issue

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for Oracle in Delphi and C++Builder
Post Reply
mmalinow
Posts: 25
Joined: Sat 14 May 2011 00:56

TSQLTimeStamp Validation Issue

Post by 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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TSQLTimeStamp Validation Issue

Post by 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;

mmalinow
Posts: 25
Joined: Sat 14 May 2011 00:56

Re: TSQLTimeStamp Validation Issue

Post by mmalinow » Thu 02 Aug 2012 12:06

Hello,

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

Mike Malinowski

Post Reply