如何在C#和SQL Server中使用加法 [英] How do I use addition with C# an sql server

查看:115
本文介绍了如何在C#和SQL Server中使用加法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我要感谢对我有帮助的所有人.

现在是一个由两部分组成的问题.

我创建了一个表,供用户使用编号.
我有另一个表格,我希望根据那里的条目将数字加起来.


示例表

表1
列:customerid,customeraccountnumber,customerpurchase,item1,item2
table2
列:customerid,购买,totatdollaramout,totalitem1,totalitem2

我从那里开始有一个条目,并且有一个datagridview在条目之后显示信息.

输入到第一个表中的数据也用于报告
因为考虑到每次客户输入购买内容时都尝试添加,但他们希望查看模式.


我只需要一个示例代码.

First I would like to thank any and everyone that has help me.

Now for the a two part question.

I create a table that a user inter numbers.
I have another table where I would like for the numbers to add up in according to there entry.


example tables

table1
columns: customerid, customeraccountnumber, customerpurchase, item1, item2
table2
columns: customerid, purchases, totatdollaramout, totalitem1, totalitem2

I on from that has entry and a datagridview to show information after entry.

the data that is entered into the first table is also used for reports
because thought about just trying add every time client entered a purchase but they want to see patterns.


I just need an example of the code.

推荐答案

您不需要第二个表.您可以在SQL中使用SUM函数来获取总数.
You don''t need the second table. You can use a SUM function in your SQL to get the totals.


这篇关于如何在C#和SQL Server中使用加法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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