Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 13th, 2004, 07:27 PM
Authorized User
Join Date: Mar 2004
Location: Rawang, Selangor, Malaysia.
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shows monthly records

I need to retrieve data from a database and show them as a monthly record in a datagrid. for example, i have the following data:

reportId | createdate | ExpenseSub
-------- | ---------- | ---------
1 | 10/20/2003 | Buy a PC
2 | 10/29/2003 | Buy a Notebook
3 | 11/1/2003 | Go to travel
4 | 11/19/2003 | Buy present for cousin
. . .
. . .
. . .
12 | 2/28/2004 | Mom's birthday
13 | 3/1/2004 | Other expenses

================================================== ======

and would like to show it using a datagrid as follow

<b>Monthly report on expenses</b>
| Records | Total Records |
| October 2003 | 2 |
| November 2003 | 2 |
| . . |
| . . |
| . . |
| February 2004 | 1 |
| March 2004 | 1 |

can anybody has any idea on this?

Reply With Quote
  #2 (permalink)  
Old May 14th, 2004, 07:34 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts

create a function that counts the days based on the month. Similar to this:

Private Function countDays(ByVal myDate As Date)
    Dim strConn As String = ConfigurationSettings.AppSettings("dbLogs")
    Dim objConn As New OleDbConnection(strConn)

    Dim strSQL As String = "SELECT Count(the_date) FROM logging WHERE (the_date = #" & myDate & "#)"

    Dim objCommand As New OleDbCommand(strSQL, objConn)

    Dim sResult As String
    sResult = CType(objCommand.ExecuteScalar(), String)

    Return sResult
End Function

Then I call the above function in another function and match days for a calendar. Below:

Sub calendar_dayrender(ByVal s As Object, ByVal e As DayRenderEventArgs)
    Dim strConn As String = ConfigurationSettings.AppSettings("dbLogs")
    Dim objConn As New OleDbConnection(strConn)

    Dim strSQL As String = "SELECT DISTINCT the_date FROM logging" ' & _
    Dim objAdapter As New OleDbDataAdapter(strSQL, strConn)
    ' DataSet & Adapter & Table

    Dim objDataSet As New DataSet
    objAdapter.Fill(objDataSet, "Fall")
    Dim strEvents
    Dim row As DataRow
    e.Day.IsSelectable = False

    For Each row In objDataSet.Tables("Fall").Rows

    Dim eventDate As DateTime = CType(row("the_date"), DateTime)
    If eventDate.Equals(e.Day.Date) Then
        strEvents = "<br /><b>" & countDays(row("the_date")) & " Visitors</b><br />"
        e.Cell.Controls.Add(New LiteralControl(strEvents))
    End If

End Sub

This should give you an idea although it's not by month. You will have to create the function to look for months instead of the calendar_dayrender.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Monthly Calendar Report (Ch9) mruschetti BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 6 May 7th, 2008 11:43 PM
To solve the Exception in Monthly recurring events amoghgr C# 0 August 21st, 2007 06:21 AM
imap_open() shows page cannot dispalyed vibinkrish Pro PHP 0 March 1st, 2006 11:18 AM
Desc sorted monthly report across several year Fehrer Access 11 February 7th, 2004 01:26 PM
Combobox that shows what's not in its list Mitch Access 6 September 18th, 2003 11:00 AM

All times are GMT -4. The time now is 07:11 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.