ROUND does not work in expression

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
 
M

Miha Markic [MVP C#]

Hi,

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

Guest

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


.
 
M

Miha Markic [MVP C#]

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


.
 
D

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


.


.
 

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