Computed Column

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
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!!!!!!
 
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.
 
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
 
Back
Top