Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2004, 07:27 PM
Authorized User
 
Join Date: Mar 2004
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?


 
Old May 14th, 2004, 07:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
    objConn.Open()
    sResult = CType(objCommand.ExecuteScalar(), String)
    objConn.Close()

    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

    Next
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.





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





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