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

May 13th, 2004, 08:27 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Location: Rawang, Selangor, Malaysia.
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|

May 14th, 2004, 08: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
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |