如何使用c sharp中的sql值进行平均值 [英] how to work average with value from sql in c sharp

查看:74
本文介绍了如何使用c sharp中的sql值进行平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的I.T.爱好者


我需要帮助,目前我正在开展调查问卷解决方案项目,其中包括输入调查问卷的结果(保存在sql数据库中),然后平均给出了一些问题。


当我需要处理平均问题时我遇到了麻烦


我的一个问题是有七个文本框,涵盖从0到60岁的年龄,用户必须在文本框中输入

特定群体中的人数。(如下所示)


0-10 [文本框]< - 输入用户在该组家庭中的人数

11-20 [文本框]

21-30 [文本框]

31-40 [文本框]

41-50 [文本框]


我到目前为止工作的代码是下面的代码。我认为问题是我放置箭头的地方

展开 | 选择 | Wrap | 行号

解决方案

为什么要解析SQL字符串?这没有任何意义。


如果你想获得平均值,为什么不用SQL?

<跨度类= codeLink 的onclick = 模糊(此,this.parentNode.parentNode,的getChildren(本),TRUE);>展开 | 选择 | Wrap | 行号


如何在文本框中显示值


thanx


< blockquote>您将显示当前显示它的方式。您只需抓取单个值,而不是尝试单步执行记录集并计算平均值。


dear I.T. lovers

I''m in need of assistance ,currently I''m working an Questionnaire solution project that consists inputting results of a questionnaire(saved in sql database) and then an average of certain questions is given.

I''m having trouble when i need to work the average of the questions

one of my question is there are seven text boxes that cover ages from 0 till 60 that the user has to input in the text boxes
the amount of people that are in a certain group of age.(sort of like below)

0-10 [text box]<--enter amount of people that the user has in the family of that group
11-20 [text box]
21-30 [text box]
31-40 [text box]
41-50 [text box]

the code that i have worked till now is the one below.i think the trouble is where i placed the arrows

Expand|Select|Wrap|Line Numbers

解决方案

Why are you parsing the SQL string? That doesn''t make any sense.

If you''re trying to get an average, why don''t you just use SQL?

Expand|Select|Wrap|Line Numbers


how do i display the value in a textbox

thanx


You would display it how you currently display it. You would just be grabbing the single value instead of trying to step through a recordset and calculating the average.


这篇关于如何使用c sharp中的sql值进行平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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