Sunday, April 5, 2009

C# - Column name which contains spaces in DataTable.Compute

DataTable.Compute Method

Namespace: System.Data
Assembly: System.Data (in System.Data.dll)

public Object Compute(
string expression,
string filter
)

Return Value
Type: System..::.Object
An Object, set to the result of the computation.


Example - When you have a column name in your datatable which
contains space, you have to keep that name inside square brackets,
like [my column name]:


...
txtMyTextBox.Text =
myDtaTbl.Compute("SUM([my column name])", "").ToString();
...

Share/Bookmark

No comments: