Concatenate

G

Guest

Is there an easy way to concatenate two columns (i.e. last name and first
name columns) in a data set so both can show up in a data text field of a
combo box?
 
M

Mark Rae

Mike Moore said:
Is there an easy way to concatenate two columns (i.e. last name and first
name columns) in a data set so both can show up in a data text field of a
combo box?

Easiest way is to do it in your SQL statement e.g.

SELECT <...other columns...>, FirstName + ' ' + LastName As FullName,
<...other columns...>
FROM <...table(s)...>
WHERE <...criteria...>

Then bind your combo box to the FullName field
 
G

Guest

This solves the problem by doing the query a special way, which I already
thought was possible, but more work.

what I wanted was a way to combine two columns *after* a query was performed
by setting the datatextfield property a certain way.

Mike Moore
 
M

Mark Rae

but more work.

Hardly... :)
what I wanted was a way to combine two columns *after* a query was
performed
by setting the datatextfield property a certain way.

I don't believe so. However, you could abandon the DataSource() and
DataBind() method of populating the dropdown and instead iterate through the
records in the DataSet / DataReader, concatenate the two name fields and
then add them to the dropdown using its Items.Add() method.

However, I think you'll find that is certainly more work...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top