如何获得最大值??? [英] How to get the max value???

查看:80
本文介绍了如何获得最大值???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的vb用户,

请问如何从以下情况中获取最大值?


数据集名称: dataset11

表名:员工

列名:StaffID


语法是???

txtMaxStaffID.text = dataset11.Employee.StaffIDColumn。????????

THX !!!

解决方案

< blockquote> Hi Gene,


您可以使用DataTable的Select方法,但我不确定它是否支持$(b)b支持像MAX()这样的聚合函数。如果不是,你应该在DataTable的所有行上迭代

,并在这个

列中找出最大值。

据我所知,DataColumn类本身并没有提供

这样的功能,因此没有什么可以取代???????

占位符在你的例子中。


-

Dmitriy Lapshin [C#/ .NET MVP]

X-Unity测试工作室
http:// x-unity .miik.com.ua / teststudio.aspx

将单元测试的强大功能带到VS .NET IDE


" Gene" < EU ******* @ hotmail.com>在消息中写道

news:u5 ************* @ TK2MSFTNGP09.phx.gbl ...

我是新的vb用户,我可以问一下如何从以下情况中获取最大值?

数据集名称:dataset11
表名:Employee
列名:StaffID

语法是???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn。????????
THX !!!




thx !!!

我会试试


Dmitriy Lapshin [C#/ .NET MVP]" < X - **** @ no-spam-please.hotpop.com> ????

新闻:eR ************** @ TK2MSFTNGP09.phx.gbl ??? ...

Hi Gene ,

你可以使用DataTable的Select方法,但我不确定它是否支持像MAX()这样的聚合函数。如果它不是,你应该在DataTable中的所有行上迭代
并在这个
列中找出最大值。

据我所知, DataColumn类本身并没有提供这样的功能,所以在你的例子中没有任何东西可以取代???????
占位符。

- -
Dmitriy Lapshin [C#/ .NET MVP]
X-Unity测试工作室
http://x-unity.miik.com.ua/teststudio.aspx
将单元测试的强大功能带到VS .NET IDE中>
基因 < EU ******* @ hotmail.com>在消息中写道
新闻:u5 ************* @ TK2MSFTNGP09.phx.gbl ...

我是新的vb用户,
请问如何从以下情况中获取最大值?

数据集名称:dataset11
表名:Employee
列名:StaffID

语法是???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn。????????
THX !!!



" Gene" < EU ******* @ hotmail.com>在消息中写道

news:u5 ************* @ TK2MSFTNGP09.phx.gbl ...

我是新的vb用户,我可以问一下如何从以下情况中获取最大值?

数据集名称:dataset11
表名:Employee
列名:StaffID

语法是???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn。????????




ADO.NET小组将更好地回答这个问题。但是,我认为*你可以通过以下两种方式实现:


1)在实际的SQL语句中选择所需列的聚合:


SELECT MAX(StaffID)FROM [员工]

GROUP BY {在此处添加您的分组字段}


那将是返回1列,最大值基于您的分组。


2)(不确定这是否有效)尝试使用
$ b中的MAX函数$ b选择DataSet上的查询:


dataset11.Select(" SELECT MAX(StaffID)FROM [EMPLOYEE] ...")


这与前一个方法相同,但它都执行客户端,

在服务器滥用方面要好得多。我认为它返回一个

DataRowView或DataRow()。如果你有这个方法的问题,

检查DataSet.Select()方法的文档。

HTH,

Jeremy


Hi, i''m a new vb user,
may i ask how to get the max value from the followin situation?

Dataset name: dataset11
Table name: Employee
Column name: StaffID

the syntax is???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn.????????
THX!!!

解决方案

Hi Gene,

You can possibly use DataTable''s Select method, but I am not sure it
supports aggregate functions like MAX(). If it doesn''t, you should iterate
on all the rows in the DataTable and find out the maximum value in this
column.

To the best of my knowledge, the DataColumn class itself does not provide
such functionality so there is nothing that could replace the "???????"
placeholder in your example.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Gene" <eu*******@hotmail.com> wrote in message
news:u5*************@TK2MSFTNGP09.phx.gbl...

Hi, i''m a new vb user,
may i ask how to get the max value from the followin situation?

Dataset name: dataset11
Table name: Employee
Column name: StaffID

the syntax is???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn.????????
THX!!!




thx!!!
I''ll try on that

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> ???
news:eR**************@TK2MSFTNGP09.phx.gbl ???...

Hi Gene,

You can possibly use DataTable''s Select method, but I am not sure it
supports aggregate functions like MAX(). If it doesn''t, you should iterate
on all the rows in the DataTable and find out the maximum value in this
column.

To the best of my knowledge, the DataColumn class itself does not provide
such functionality so there is nothing that could replace the "???????"
placeholder in your example.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Gene" <eu*******@hotmail.com> wrote in message
news:u5*************@TK2MSFTNGP09.phx.gbl...

Hi, i''m a new vb user,
may i ask how to get the max value from the followin situation?

Dataset name: dataset11
Table name: Employee
Column name: StaffID

the syntax is???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn.????????
THX!!!



"Gene" <eu*******@hotmail.com> wrote in message
news:u5*************@TK2MSFTNGP09.phx.gbl...

Hi, i''m a new vb user,
may i ask how to get the max value from the followin situation?

Dataset name: dataset11
Table name: Employee
Column name: StaffID

the syntax is???
txtMaxStaffID.text = dataset11.Employee.StaffIDColumn.????????



This question will be better answered by the ADO.NET group. However, I
*think* you can accomplish this two ways:

1) select an aggregate of the desired column in your actual SQL statement:

SELECT MAX( StaffID ) FROM [Employee]
GROUP BY {add your grouping fields here}

That will return 1 column, with the max values based on your grouping.

2) (not sure if this will work or not)Try using the MAX function in the
select query on the DataSet:

dataset11.Select("SELECT MAX(StaffID) FROM [EMPLOYEE]...")

This is the same as the previous method, but it all executes client side,
wich is much better in terms of server abuse. I think it returns either a
DataRowView, or a DataRow( ). If you are having problems with this method,
check the documentation on the DataSet.Select() method.
HTH,
Jeremy


这篇关于如何获得最大值???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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