如何转换数据表列类型? [英] How To Convert The DataTable Column type?

查看:337
本文介绍了如何转换数据表列类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现:

dtGroupedBy.Compute("sum(POWER)",dvv.RowFilter); 



这会导致一个错误的:

It results of an error:

集合函数sum()和类型的无效使用。字符串

Invalid usage of aggregate function Sum() and Type: String.

我们如何将其转换成其列类型??

How would we convert it to its column type ??

推荐答案

计算方法支持表情和他们所支持的 CONVERT函数,你可以在表达式内使用。

Compute method supports expressions and they support the CONVERT function that you could use inside of the expression.

例如,你可以计算出列的总和像

For example, you could calculate sum of the column like

MyDataTable.Compute("Sum(Convert(your column name, 'Data Type'))") 

这篇关于如何转换数据表列类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆