C# function within DataReader query

  • Thread starter Thread starter st
  • Start date Start date
S

st

Hi,

I've a parameterised query that is used as the basis for an Excel
export. I need to add an additional column that doesn't map to a field
in my SQL table. What I have done in the past in my Access apps is to
include a function I've created in the query SQL.

Is there a way to achive the same with C#/ado.net?

Many thanks,

Simon Lane
 
Are you populating a dataset? If so, just add a column to the table once
you've filled your dataset.
 
Hi Simon,
From MSDN:

You can define an expression for a column, enabling it to contain a
value calculated from other column values in the same row or from the
column values of multiple rows in the table. To define the expression
to be evaluated, use the Expression property of the target column, and
use the ColumnName property to refer to other columns in the
expression. The DataType for the expression column must be appropriate
for the value the expression will return.

See:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataColumnClassExpressionTopic.asp

Hope it helps,

Grtz, Wouter van Vugt
Infosupport - Netherlands
http://www.infosupport.com
http://blogs.infosupport.com/wouterv
 
Back
Top