Hello,
I noticed that dbExpress creates TStringField for the UniqueIdentifier fields. Can I change the format of the resulting string somehow? In particular I'd like to remove curly brackets.
Uniqueidentifier string format
Hello,
To remove curly brackets from the uniqueidentifier column, you can use persistent fields and the OnGetText event handler in the following way:
To remove curly brackets from the uniqueidentifier column, you can use persistent fields and the OnGetText event handler in the following way:
Code: Select all
procedure TMainForm.ClientDataSetuidGetText(Sender: TField; var Text: String;
DisplayText: Boolean);
begin
Text := Copy(Sender.AsString, 2, Length(Sender.AsString) - 2);
end;
This is of course possible, but I can't use such approach(persistent fields) in my case. The application would have to handle every uniqueidentifier field this way explicitly, but it simply doesn't know them:-(( Moreover, the described solution might work with dbGrid, but not when applying filters on the dataset - I guess.AndreyZ wrote:Hello,
To remove curly brackets from the uniqueidentifier column, you can use persistent fields and the OnGetText event handler in the following way:Code: Select all
procedure TMainForm.ClientDataSetuidGetText(Sender: TField; var Text: String; DisplayText: Boolean); begin Text := Copy(Sender.AsString, 2, Length(Sender.AsString) - 2); end;
I'd rather have dbExpress driver (or the underlaying sql server client library) configured to behave the required way for every uniqueidentifier field in the database implicitly - if possible.
You can cast uniqueidentifier fields to string in the following way:
Code: Select all
SQLQuery.SQL.Text := 'select cast(uid as varchar(40)) uid from tablename';
ClientDataSet.Open;