如何在C#中使用.net从数据集中获取最大数值 [英] how to get maimum values from data set using .net with c#

查看:88
本文介绍了如何在C#中使用.net从数据集中获取最大数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我对条件(max,min,select querey)的数据集中的推定值感到怀疑

我将告诉您我的情况:现在正在打开数据库并检查表中的最大值并将记录插入表中[每条记录都发生这种情况]

我不想一直打开数据库.我的想法是,打开数据库并设置值数据集.然后,在没有打开数据库的情况下,我只需要检查数据集并获取最大值,相应地插入记录.

请对此提供帮助..谢谢您的帮助.

Hi Friends,

I have doubt regarding for reterive values from data set with condition( max,min,select querey)

i will tell you my scenario : right now am opening data base and check maximum values from table and insert the records into table [ this was happen every record]

i dont want open all the time data base. my ideas was , open data base and set the values data set. then, with out opening data base just i have to check data set and get maximum value insert the record accordingly .

Please help on this.. thank you for advance who are helping.

推荐答案

此方法存在许多问题,主要涉及本地商店未反映出实际数据.

1)您将必须手动使用新的最大值更新数据集.
2)如果一个人使用数据库,会发生什么?毕竟,这首先就是使用数据库的主要原因之一.如果没有适当的机制来与其他用户更改更新数据集,那么一切都会很快崩溃.

你为什么做这个?要么使用数据库中的身份规范字段(这样,当您插入新记录时它就会自动增加),或者通过存储过程将其保留在数据库中并防止数据库与您的代码之间往返.
There are a number of problems with this approach, mostly concerned with the local store not reflecting the actual data.

1) You will have to manually update the dataset with the new maximum.
2) What happens if more than one person is using the database? Which is after all one of the main reasons for using a database in the first place... If you do not have some mechanism in place for updating the dataset with other users changes, then it all falls to pieces very quickly.

Why are you doing this? Either use an identity specification field in the DB (so it is incremented automatically when you insert a new record), or do it via a stored procedure to keep it all in the DB and prevent a round trip between DB and your code.


是的,可以实现用户过滤.
使用数据表的Select方法,可以获得数据表中的最大值.
例如使用
Yes, User Filters it can be achieved.
Using Select method for the datatable, you can get the maximum value in the datatable.
For instance use
DataTable dt = new DataTable["Student"];
dt.Select("Max(id");


程序正确,语法不同


procedure is correct, syntax is different


这篇关于如何在C#中使用.net从数据集中获取最大数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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