计算数据库DataGridView列 [英] Calculate Database DataGridView Column

查看:89
本文介绍了计算数据库DataGridView列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在做一个小项目,但有一个小问题:)
我有一个包含6列的数据库.加载Form1时,我想从"TotalPrice"列中查看Label1中的总金额.

这可能吗?
谢谢.

我使用Visual Basic 2010

Hi to all of you,
I''m working on a small project and I have a small problem :)
I have a database with 6 columns. When I load Form1, I want to see calculate total amount in Label1 from Column "TotalPrice".

Is this possible?
Thank you.

I use Visual Basic 2010

推荐答案

是的,这是可能的:

使用以下SQL语句:
Yes this is possible :

Use the following SQL statement :
SELECT Sum(TotalPrice) FROM TableName



这将返回一个包含TotalPrice列中所有值之和的单个值.

祝你好运!
爱德华(Eduard)



This will return a single value containing the sum of all values in the TotalPrice columns.

Good luck!
Eduard


您是否在数据库中有数据,或者是否要根据datagridview列中当前的值来计算总数?

如果是后者,则下一个问题是数据来自何处?例如,如果它来自数据表,则可以使用计算 [^ ]方法.
Do you have the data in the database or do you want to calculate the total based on the values currently in a datagridviewcolumn?

If it''s the latter, the next question is where the data is coming from? If it''s for example from a DataTable, then you could use Compute[^] method.


这篇关于计算数据库DataGridView列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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