Computed Column

J

Jim Heavey

Hello, I think you can create a column in a datatable which is computed
based upon other columns in the datatable, but I am not sure how to do
this.

Say you have a table with "FirstName" and "LastName" and you want to create
a column in the data table which equates to "LastName" + ", " +
"FirstName". How would you do this?

If you add the column to the table, how will this effect the setting of
MissingMappingAction and MissingSchemaAction properties on the dataAdapter?

Thanks in advance for your assistance!!!!!!
 
M

Miha Markic

Hi Jim,


Jim Heavey said:
Hello, I think you can create a column in a datatable which is computed
based upon other columns in the datatable, but I am not sure how to do
this.

Say you have a table with "FirstName" and "LastName" and you want to create
a column in the data table which equates to "LastName" + ", " +
"FirstName". How would you do this?

Set column's datatype to string and expression to "LastName + ',' +
FirstName"
See DataColumn.Expression .net help topic.
If you add the column to the table, how will this effect the setting of
MissingMappingAction and MissingSchemaAction properties on the
dataAdapter?

It shouldn't affect as it is an added column.
 
R

Rob Panosh

If you are populating you data table from SQL then you could simply add this
to your SQL Select statement.

MSS:
Select Rtrim(LastName) + ', ' FirstName As FullName From ...

Oracle:
Select Rtrim(LastName) || ', ' || FirstName As Fullname From ...

Regards,
Rob Panosh
 

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

Top