I have a collection of objects populated from a SQL Server (sorted
descending). Each of these object has a date field.
I need a way to loop through these object starting from the newest
entry, and finishing at the last, and output them in the format:
June 2007
Item
Item
Item
May 2007
Item
Item
....
....
....
....
December 2006
Item
Item
..... and so on.
I have no idea how to achieve this, so if someone could help me that
would be great. 7 1657
Mick Walker <Mi*********@privacy.netwrote in news:5djhv5F34s3l4U1
@mid.individual.net:
I have a collection of objects populated from a SQL Server (sorted
descending). Each of these object has a date field.
I need a way to loop through these object starting from the newest
entry, and finishing at the last, and output them in the format:
In your SQL statement, sort the list by date. Then use a datareader (or
dataset) to output the data.
Mick,
Probably I would try to get the Top 1 record, using the Execute Scalar,
order the table by the DateTime and where the date is than the previous
date.
Avoiding to give you the fish but help you to learn how to fish.
Cor
"Mick Walker" <Mi*********@privacy.netschreef in bericht
news:5d*************@mid.individual.net...
>I have a collection of objects populated from a SQL Server (sorted descending). Each of these object has a date field.
I need a way to loop through these object starting from the newest entry,
and finishing at the last, and output them in the format:
June 2007
Item
Item
Item
May 2007
Item
Item
...
...
...
...
December 2006
Item
Item
.... and so on.
I have no idea how to achieve this, so if someone could help me that would
be great.
Cor Ligthert [MVP] wrote:
Mick,
Probably I would try to get the Top 1 record, using the Execute Scalar,
order the table by the DateTime and where the date is than the previous
date.
Avoiding to give you the fish but help you to learn how to fish.
Cor
Thanks for your reply Cor.
However I am still no wiser at the moment. I know what I wish to do, I
am just unsure of how to do it.
I need to loop though my collection,
Process Items Which Are in current Month
Write Heading
Write Items
Process Items Which Are in current Month -1
Write Heading
Write Items
Process Items Which Are in current Month -2
Write Heading
Write Items
Process Items Which Are in current Month -3
Write Heading
Write Items
......
I would like to keep the result set to a max of 6 months.
Any ideas?
Regards
Mick
Mick Walker wrote:
I have a collection of objects populated from a SQL Server (sorted
descending). Each of these object has a date field.
I need a way to loop through these object starting from the newest
entry, and finishing at the last, and output them in the format:
June 2007
Item
Item
Item
May 2007
Item
Item
...
...
...
...
December 2006
Item
Item
.... and so on.
I have no idea how to achieve this, so if someone could help me that
would be great.
Keep track of the year and month, and check against each item that you
output. When it changes, output a new header.
--
Göran Andersson
_____ http://www.guffa.com
"Mick Walker" <Mi*********@privacy.netwrote in message
news:5d*************@mid.individual.net...
Cor Ligthert [MVP] wrote:
>Mick,
Probably I would try to get the Top 1 record, using the Execute Scalar, order the table by the DateTime and where the date is than the previous date.
Avoiding to give you the fish but help you to learn how to fish.
Cor
Thanks for your reply Cor.
However I am still no wiser at the moment. I know what I wish to do, I am
just unsure of how to do it.
I need to loop though my collection,
Process Items Which Are in current Month
Write Heading
Write Items
Process Items Which Are in current Month -1
Write Heading
Write Items
Process Items Which Are in current Month -2
Write Heading
Write Items
Process Items Which Are in current Month -3
Write Heading
Write Items
What do you mean? Are you talking about looping through a collection class
with a collection of objects.
If that's what you're talking about then you use a Foreach loop
Foreach item as theobject in Collection
if item.Date = current Month then
do something
endif
if item.Date = current Month -1 then
do something
endif
next
Or if you're talking about a SQL recordset, then you use a ADO.Net
Datareader and loop through the resultset.
while dr Not EOF
if dr.Date = current Month then
do something
endif
loop
It's really not clear as to what you're asking.
Mick,
Something like this, executed with a command.executescalar seems proper for
me.
(where here the orders from the Northwind database is used)
Select Top 1 OrderDate From Orders Where OrderDate @previousdate' Order By
OrderDate
Cor
"Mick Walker" <Mi*********@privacy.netschreef in bericht
news:5d*************@mid.individual.net...
Cor Ligthert [MVP] wrote:
>Mick,
Probably I would try to get the Top 1 record, using the Execute Scalar, order the table by the DateTime and where the date is than the previous date.
Avoiding to give you the fish but help you to learn how to fish.
Cor
Thanks for your reply Cor.
However I am still no wiser at the moment. I know what I wish to do, I am
just unsure of how to do it.
I need to loop though my collection,
Process Items Which Are in current Month
Write Heading
Write Items
Process Items Which Are in current Month -1
Write Heading
Write Items
Process Items Which Are in current Month -2
Write Heading
Write Items
Process Items Which Are in current Month -3
Write Heading
Write Items
.....
I would like to keep the result set to a max of 6 months.
Any ideas?
Regards
Mick
On Jun 16, 6:44 pm, Mick Walker <Mick.Wal...@privacy.netwrote:
I have a collection of objects populated from a SQL Server (sorted
descending). Each of these object has a date field.
I need a way to loop through these object starting from the newest
entry, and finishing at the last, and output them in the format:
June 2007
Item
Item
Item
May 2007
Item
Item
...
...
...
...
December 2006
Item
Item
.... and so on.
I have no idea how to achieve this, so if someone could help me that
would be great.
Try this:
dim tempDate as item(1).date
do while tempDate < item(n).date
...
tempDate = tempDate.addDays(1)
loop
and so on... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Beau |
last post by:
Hi all, thanks in advance.
Ok, heres the story.
What is happening......
--------------------------------
I've got an ASP page that loops.
It loops in order to get data in different,...
|
by: Scott |
last post by:
I have a collection where the items in the collection are dates. I want to
iterate over the collection and build a value list string for the rowsource
of a listbox. The dates in the collection are...
|
by: Trevor Best |
last post by:
I did a test once using a looping variable, first dimmed as Integer,
then as Long. I found the Integer was quicker at looping. I knew this to
be true back in the 16 bit days where the CPU's (80286)...
|
by: TD |
last post by:
This is the code under a command button -
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl
|
by: VB Programmer |
last post by:
Here's the code:
For Each li As ListItem In Me.lstAssignedEmailAddresses.Items
If li.Selected = True Then
Me.lstAssignedEmailAddresses.Items.Remove(li)
End If
Next
When I remove an item I get...
|
by: Chet Cromer |
last post by:
I am creating a set of base classes and sub classes to use throughout a
program I'm developing. The base class represents a generic "lookup
table" from my database that contains lists of things...
|
by: Peter Parker |
last post by:
Does anyone know if there is a method or property in php5 that provides the
collection size in XML processing? For example,
$collection=$doc->getElementsByTagName("someTag");
where one can get...
|
by: Mick Walker |
last post by:
I have a collection of objects populated from a SQL Server (sorted
descending). Each of these object has a date field.
I need a way to loop through these object starting from the newest
entry,...
|
by: zags |
last post by:
I have a date parameter for a query that I'm using to update a table. I need to run the query several times using a different date each time its run. The dates are pay period end dates that are...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |