在ADO.Net中使用聚合函数 [英] Using Aggregate functions in ADO.Net

查看:89
本文介绍了在ADO.Net中使用聚合函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次问好,

现在我已经掌握了ADO.NET的基础知识,我想在ado.net字符串命令中使用聚合函数。

Now that I have gotten the basics of ADO.NET, I would like to use aggregate functions within ado.net string commands.

我如何将聚合函数用于最简单的潜力?

How would I use aggregate functions to its simplest potential?

例如:

   Public Sub BindData()

        Dim connection As New OleDb.OleDbConnection(strDBFileX)
        Dim dataadapter As New OleDb.OleDbDataAdapter("SELECT DISTINCT MAX(EmailAddresses.EmailAddressID)+1 as NewEMailAddressID , EmailAddresses.EmailAddress, EmailAddresses.AddressID FROM EmailAddresses WHERE EmailAddresses.AddressID=" & AddressIDTextBox.Text.ToString, connection)
        Dim ds As New DataSet()
        connection.Open()
        dataadapter.Fill(ds, "EmailAddresses")
        connection.Close()
        EmailAddressesDataGridView.DataSource = ds
        EmailAddressesDataGridView.DataMember = "EmailAddresses"

    End Sub

欢迎任何用户在方便时改进此例程。

Any user is welcome to improve this routine at their convenience.

注意必须声明聚合函数。

Note that An aggregate function has to be declared.

用户想要完成的是通过提供Max聚合函数加1来添加新记录;因此,将创建一个新记录 

What the user wants to accomplish is to add a new record by providing a Max aggregate function plus one; thus, a new record 

或行。

问候,

JohnDBCTX

JohnDBCTX

jp

推荐答案

https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetdataproviders

https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetdataproviders

这是你应该发布的地方。

It's where you should post.


这篇关于在ADO.Net中使用聚合函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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