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