简体   繁体   English

如何在Access 2003中实现计算

[英]How to implement calculation in access 2003

I have an access database that am trying to add some calculation and use my c# application to pull data using a dataGridView , 我有一个access database ,试图添加一些计算并使用我的c#应用程序使用dataGridView提取数据,

I have about 14 fields in this particular table, I was wondering if there is way 我在此特定表中大约有14个字段,我想知道是否有办法

I could perform a calculation from field 1 based on field 11 and 12? 我可以根据字段1112?field 1执行计算12? both field 11 and 12 are accepts numbers and so too field 1 I want field one to have data that is as field1==>{field11-field12) How can I accomplish this in access 2003. 字段1112都接受数字,因此字段1我也希望字段1具有如下数据: field1==>{field11-field12)如何在Access 2003中完成此操作。

Create a query in Access, then you can enter the calculation as a new field in that query. 在Access中创建查询,然后可以在该查询中将计算结果作为新字段输入。 When you create the query, Access will give you a series of checkboxes where you can select which fields you want in the result. 创建查询时,Access将为您提供一系列复选框,您可以在其中选择想要在结果中的哪些字段。

It is easiest to add the calculation if you go to SQL view in the query editor. 如果您在查询编辑器中进入SQL视图,最简单的方法就是添加计算。 Then you will see something like 然后您会看到类似

select field2, field3, field4 from SomeTable

and you want to add your calculation as a new column 并且您想将计算添加为新列

select field2, field3, field4, (field11 - field12) as fieldDifference from SomeTable

Then save your query. 然后保存您的查询。

In your C# code, instead of having the data source refer to the table name ( SomeTable in this example) use the name that you saved the query as. 在您的C#代码中,不要让数据源引用表名(在本示例中为SomeTable ),而是使用您将查询另存为的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM