-
Aug 23rd, 2019, 08:58 AM
#1
Thread Starter
Lively Member
[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.
-
Aug 23rd, 2019, 09:54 AM
#2
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Aug 23rd, 2019, 10:25 AM
#3
Thread Starter
Lively Member
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.
-
Aug 23rd, 2019, 11:44 AM
#4
Re: Concatenate two NChar data type columns
Yes... NCHAR data type always store the full size even if it is less
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Aug 23rd, 2019, 03:22 PM
#5
Thread Starter
Lively Member
Re: Concatenate two NChar data type columns
Thanks - done and it works!
A.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|