p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > Other .NET > General .NET
I forgot my password Register Now
Register | FAQ | Members List | Calendar | 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 13th, 2004, 08:27 PM
Authorized User
Points: 146, Level: 2
Points: 146, Level: 2 Points: 146, Level: 2 Points: 146, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 14th, 2004, 08:34 AM
Friend of Wrox
Points: 2,549, Level: 20
Points: 2,549, Level: 20 Points: 2,549, Level: 20 Points: 2,549, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 8th, 2008 12:43 AM
To solve the Exception in Monthly recurring events amoghgr C# 0 August 21st, 2007 07: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 12:00 PM



All times are GMT -4. The time now is 01:29 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc