女士访问的最大价值 [英] maximum Value from Ms access

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

问题描述

我想从一列ms访问数据库中获取最大值

我使用了以下代码:

dr2 = obj.SelCommand(从tbl_registercomplaints中选择max([ID])");

int n = Convert.ToInt32(dr2.Read());

这里dr2是datareader的对象,而obj是包括选择命令定义的类的对象.

在上述情况下,它仅返回一个值及其"1"
每当n的值为1时.

查询分析器显示正确的结果.

请帮助我找到解决方案.


Kishore R
吉斯解决方案
www.uniquewebdeveloper.co.cc

I want to take maximum value from a column of ms acess data base

i used the following code:

dr2=obj.SelCommand("select max([ID]) from tbl_registercomplaints");

int n = Convert.ToInt32(dr2.Read());

here dr2 is an object of datareader and obj is an object of class which includes definition for selection command.

in the above case,its returns only one value and its ''1''
every time the value of n is 1.

the query analyser shows the correct result.

please help me to find a solutions for this.


Kishore R
Gis Solutions
www.uniquewebdeveloper.co.cc

推荐答案

IDataReader.Read()返回bool,如果读取了一行,则为true.

您需要获取该行中第一个字段的值.这是执行此操作的一种方法:

IDataReader.Read() returns a bool which is true if a row was read.

You need to get the value of the first field in that row. Here is one way to do that:

int maxId = dr2.GetInt32( 0 );



尼克



Nick


这篇关于女士访问的最大价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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