MaxValue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

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


thanks
 
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
 
and how to get the first and last record using the dataset facilities
--
Regads,
Rochdi


Carlos J. Quintero said:
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
 
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.
 
Sorry but I meant from the dataset or reader not from a table in the
database!!!!
--
Regads,
Rochdi


Marcelo said:
SELECT MAX(Field)
FROM TableName


-----Original Message-----
From: Tom Shelton [mailto:[email protected]]
Posted At: Tuesday, September 20, 2005 12:27 PM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: MaxValue
Subject: Re: MaxValue

Mike said:
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.
 
SELECT MAX(Field)
FROM TableName


-----Original Message-----
From: Tom Shelton [mailto:[email protected]]
Posted At: Tuesday, September 20, 2005 12:27 PM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: MaxValue
Subject: Re: MaxValue

Mike said:
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.
 
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.
 
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 said:
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.
 
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?
 
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)")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top