ROUND does not work in expression

  • Thread starter Thread starter Dorte
  • Start date Start date
D

Dorte

In an ASP.NET application I am using the WriteXML method
of a dataset to export data to XML format. But before
exporting data, I would like to round values in a column
with the datatype double. I have tried to create a new
column and add an expression to enter values from the
source column into the target column and round the values
to having only two decimals.

ds.Tables(0).Columns.Add("Target")
ds.Tables(0).Columns("Target").Expression = "SELECT ROUND
(([Source]),2)"

It generates the following error:
"Missing operand after 'round' operator."

Can the "round" method not be used in this way?
Any help would be appreciated.

Dorte
 
Hi,

You should really read the .net help topic:
DataColumn.Expression property
 
I guess what you're saying is that what I'm trying to do
isn't possible? I must loop through the columns/rows and
format each value?

Dorte
-----Original Message-----
Hi,

You should really read the .net help topic:
DataColumn.Expression property

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

In an ASP.NET application I am using the WriteXML method
of a dataset to export data to XML format. But before
exporting data, I would like to round values in a column
with the datatype double. I have tried to create a new
column and add an expression to enter values from the
source column into the target column and round the values
to having only two decimals.

ds.Tables(0).Columns.Add("Target")
ds.Tables(0).Columns("Target").Expression = "SELECT ROUND
(([Source]),2)"

It generates the following error:
"Missing operand after 'round' operator."

Can the "round" method not be used in this way?
Any help would be appreciated.

Dorte


.
 
Hi,

Yes, there is no select keyword not Round function.
You might try using the following expression:
Convert(a * 100, 'System.Int32')/100


--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

I guess what you're saying is that what I'm trying to do
isn't possible? I must loop through the columns/rows and
format each value?

Dorte
-----Original Message-----
Hi,

You should really read the .net help topic:
DataColumn.Expression property

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

In an ASP.NET application I am using the WriteXML method
of a dataset to export data to XML format. But before
exporting data, I would like to round values in a column
with the datatype double. I have tried to create a new
column and add an expression to enter values from the
source column into the target column and round the values
to having only two decimals.

ds.Tables(0).Columns.Add("Target")
ds.Tables(0).Columns("Target").Expression = "SELECT ROUND
(([Source]),2)"

It generates the following error:
"Missing operand after 'round' operator."

Can the "round" method not be used in this way?
Any help would be appreciated.

Dorte


.
 
It works, thanks a lot!
Dorte
-----Original Message-----
Hi,

Yes, there is no select keyword not Round function.
You might try using the following expression:
Convert(a * 100, 'System.Int32')/100


--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

I guess what you're saying is that what I'm trying to do
isn't possible? I must loop through the columns/rows and
format each value?

Dorte
-----Original Message-----
Hi,

You should really read the .net help topic:
DataColumn.Expression property

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

In an ASP.NET application I am using the WriteXML method
of a dataset to export data to XML format. But before
exporting data, I would like to round values in a column
with the datatype double. I have tried to create a new
column and add an expression to enter values from the
source column into the target column and round the values
to having only two decimals.

ds.Tables(0).Columns.Add("Target")
ds.Tables(0).Columns("Target").Expression = "SELECT ROUND
(([Source]),2)"

It generates the following error:
"Missing operand after 'round' operator."

Can the "round" method not be used in this way?
Any help would be appreciated.

Dorte


.


.
 
Back
Top