I'm using ADO-components to connect to an access database. In a column defined as text with width 50, dataaware textfields always displays 50 characters even when the actual string value contains less characters. The value gets padded with spaces, and if the textfield is not wide enough, it looks like it is empty.
Anyone got any clues?
Thanks,
-Vegar
Edit: I'm using Delphi 2007.
The problem comes from using Char(50) instead of Varchar(50) when creating the table.
I still think there should be a way of displaying the unpadded value, but switching to varchar is ok.
Which version of Delphi?
And can't it be a field setting in the access database?
Are you using a query or a table component? If you are using a query then just embed the column name in Trim(). If not then use the OnGetText event on the field in question to put in the following code
Text := Trim(Text);
Related
This happened when updating text area.
If you have a valid EF model with the correct field length, this shouldn't be a problem (for example, by decorating with Length attributes)
This type of error generally occurs when you try to put characters or values more than what you have specified in your table schema.
Like in that case: you specify varchar(10), but you are trying to store a value that contains 19 characters.
Solution:
Check your parameter sizes against column sizes and the field(s)
Try updating each property one by one with a .SaveChanges() to find out which one is causing the error.
Why does the result set of Informix automatically add blank spaces to the varchar fields?
The trim function is no use. When inserting such result set into another DB, it would also contain the blank spaces.
How to filter or trim the blank spaces?
If you have a database varchar(n) field, and there are blank chars on the right of the text, they are coming from the application layer, not the engine. (For example, your column is defined as varchar(30) and your application form/screen has a text field of (30).) If the application layer does not provide a varchar field, you might see this.
Take note this is not only valid for Informix; it is valid for any transactional database engine.
I have a number field called Days and an editable names field called Names ( which allows multiple values ).
Let say that Days=1 and Names=Mike/Rock, Tom/Rock, Dean/Rock.
I want to display them in a column view like this:
1
Mike
Tom
Dean
I tried it with #NewLine, but no luck for me.
I also created a computed (hidden) field test with the following formula as default value:
#Text(Days)+#NewLine+#Implode(#Name([CN];Names);#NewLine)
It seems to be the wanted form for me, but when I just put test in a column default value, it shows nothing.
I appreciate your time.
Try to set your test field to #text(days):Names. This should create a multi-value field (as opposed to a single string which your test formula produces).
Then, set the multi-value separator of the column style to Newline, and adjust the number of rows to match the expected number of values.
In a view we get only one row for one document. Multiple values are therefore shown in one row only with multi value separator.
Eclipse view may perhaps help.
I use DBGrid to display Hyperlink type field from Microsoft Access database (MDB).
Normally dbgrid displays hyperlink values like "(MEMO)", without editing capablity. Is there a way to solve this?
DBGrid displays values based on field type. If it shows (MEMO) then you probably declared your field in your database as TEXT or something equivalent. Can't remember Access, but in MS-SQL Server you can change field type to varchar and DBGrid will display values as editable text.
I am using a DBGrid component in Delphi. I wonder how I can set the format of a column. I have real values that I want to be displayed as currency in the grid.
Someone knows how?
You can set the DisplayFormat of the Field
You can handle OnGetText event. This approach allows to do more complex operations with the value.
If you don't add the fields to field Editor list you can get the formating by code as :
TFloatField(MyQuery.fieldByName('MyField').DisplayFormat := '0.00';
if you don't want to show the zeros replace '0.00' with '#.##';
The first port of call is the DisplayFormat of the data field in the database itself.