[RESOLVED] Concatenate two NChar data type columns
Dear all,
I'm trying to bind an added data column to a Combobox.
Therefore I'm adding a column to the datatable I'm using which is made by the concatenation of two fields. Unfortunately, as the two fields are of type NChar(50) the result is that in the combobox the two fields appear with a lot of empty spaces in between.
Here below the code I'm using:
Code:
Dim Fullname As New DataColumn()
Fullname.DataType = System.Type.GetType("System.Object")
Fullname.ColumnName = "Fullname"
CTO_DataSet.Tbl_CTOAbilità .Columns.Add("FullName", GetType(String), "Nome + Cognome")
Cmb1.DataSource = CTO_DataSet.Tbl_CTOAbilitÃ
Cmb1.DisplayMember = "Fullname"
Cmb1.ValueMember = "ID"
For example, let's name field Nome is "Filippo" and Cognome is "Rossi", the result in the combobox is:
"Filippo Rossi".
How can I delete the spaces?
Thanks for the support,
A.
Re: Concatenate two NChar data type columns
I would add Trim of the fields in the SQL that you use to generate the data set.
Re: Concatenate two NChar data type columns
Dear GaryMazzone,
do you mean something like:
Code:
"SELECT Id,Codice,LTRIM(RTRIM(Nome)),LTRIM(RTRIM(Cognome)),Anno_di_nascita"
Thanks,
A.
Re: Concatenate two NChar data type columns
Yes... NCHAR data type always store the full size even if it is less
Re: Concatenate two NChar data type columns
Thanks - done and it works!
A.