By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

MaxValue

P: n/a
Hi,

How can I pls get the maxvalue and the minvalue in a specific colunm in a
dataset or datareader.
thanks
--
Regads,
Rochdi
Nov 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
If you don´t use a query with the MIN(...) and MAX(...) statements to make
the database do the calculation for you, you need to traverse the recordset
yourself to get the min and max values, or sort it by that column and get
the first and last row...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Mike" <Mi**@discussions.microsoft.com> escribió en el mensaje
news:46**********************************@microsof t.com...
Hi,

How can I pls get the maxvalue and the minvalue in a specific colunm in a
dataset or datareader.
thanks
--
Regads,
Rochdi

Nov 21 '05 #2

P: n/a
and how to get the first and last record using the dataset facilities
--
Regads,
Rochdi
"Carlos J. Quintero [VB MVP]" wrote:
If you don´t use a query with the MIN(...) and MAX(...) statements to make
the database do the calculation for you, you need to traverse the recordset
yourself to get the min and max values, or sort it by that column and get
the first and last row...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Mike" <Mi**@discussions.microsoft.com> escribió en el mensaje
news:46**********************************@microsof t.com...
Hi,

How can I pls get the maxvalue and the minvalue in a specific colunm in a
dataset or datareader.
thanks
--
Regads,
Rochdi


Nov 21 '05 #3

P: n/a
In article <46**********************************@microsoft.co m>, Mike wrote:
Hi,

How can I pls get the maxvalue and the minvalue in a specific colunm in a
dataset or datareader.
thanks


Not sure about the datareader, but you can select datarows via critera
on a datatable using the Select method.

--
Tom Shelton [MVP]
Nov 21 '05 #4

P: n/a

SELECT MAX(Field)
FROM TableName
-----Original Message-----
From: Tom Shelton [mailto:to*@YOUKNOWTHEDRILLmtogden.com]
Posted At: Tuesday, September 20, 2005 12:27 PM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: MaxValue
Subject: Re: MaxValue

In article <46**********************************@microsoft.co m>, Mike
wrote:
Hi,

How can I pls get the maxvalue and the minvalue in a specific colunm in a dataset or datareader.
thanks


Not sure about the datareader, but you can select datarows via critera
on a datatable using the Select method.

--
Tom Shelton [MVP]

Nov 21 '05 #5

P: n/a
Sorry but I meant from the dataset or reader not from a table in the
database!!!!
--
Regads,
Rochdi
"Marcelo" wrote:

SELECT MAX(Field)
FROM TableName
-----Original Message-----
From: Tom Shelton [mailto:to*@YOUKNOWTHEDRILLmtogden.com]
Posted At: Tuesday, September 20, 2005 12:27 PM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: MaxValue
Subject: Re: MaxValue

In article <46**********************************@microsoft.co m>, Mike
wrote:
Hi,

How can I pls get the maxvalue and the minvalue in a specific colunm

in a
dataset or datareader.
thanks


Not sure about the datareader, but you can select datarows via critera
on a datatable using the Select method.

--
Tom Shelton [MVP]

Nov 21 '05 #6

P: n/a
In article <8D**********************************@microsoft.co m>, Mike wrote:
Sorry but I meant from the dataset or reader not from a table in the
database!!!!


I'm refereing to a DataTable object in the dataset.

DataRow[] dr = ds.Tables[0].Select ("MAX (COLUMN)");

Basically, you can filter data from a table in a dataset, not the
database.

--
Tom Shelton [MVP]
Nov 21 '05 #7

P: n/a
in my table where my dataset is getting data from I have the colunms "ID" as
integer and "Valid" as Boolean and when applying the following statement :

dr = ds.Tables(0).Select("MAX(ID)")

I'm having the following error:

" Filter expression 'MAX(ID)' does not evaluate to a Boolean term"
how can I fix it?
--

--
Regads,
Rochdi
"Tom Shelton" wrote:
In article <8D**********************************@microsoft.co m>, Mike wrote:
Sorry but I meant from the dataset or reader not from a table in the
database!!!!


I'm refereing to a DataTable object in the dataset.

DataRow[] dr = ds.Tables[0].Select ("MAX (COLUMN)");

Basically, you can filter data from a table in a dataset, not the
database.

--
Tom Shelton [MVP]

Nov 21 '05 #8

P: n/a
In article <63**********************************@microsoft.co m>, Mike wrote:
in my table where my dataset is getting data from I have the colunms "ID" as
integer and "Valid" as Boolean and when applying the following statement :

dr = ds.Tables(0).Select("MAX(ID)")

I'm having the following error:

" Filter expression 'MAX(ID)' does not evaluate to a Boolean term"
how can I fix it?
--

--
Tom Shelton [MVP]
Nov 21 '05 #9

P: n/a
In article <63**********************************@microsoft.co m>, Mike wrote:
in my table where my dataset is getting data from I have the colunms "ID" as
integer and "Valid" as Boolean and when applying the following statement :

dr = ds.Tables(0).Select("MAX(ID)")

I'm having the following error:

" Filter expression 'MAX(ID)' does not evaluate to a Boolean term"
how can I fix it?
--


Actually, that should be something like:

dr = ds.Tables(0).Select("ID = MAX(ID)")

--
Tom Shelton [MVP]
Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.