I'm trying to write a simple online diary system using the calendar control and an access database to store the appointment details.
Basically the issue I'm having is that when the calender loads I wan't to highlight any dates that currently have appointments booked.
I've managed to do this in the DayRender event, but it dramatically slows down the function of the calendar.
I think its because I'm opening and closing the database connection too much.
By the way I'm new to ASP.Net so if I'm missing something obvious here please be gentle
Here's the DayRender Subroutine I'm using:
Basically the issue I'm having is that when the calender loads I wan't to highlight any dates that currently have appointments booked.
I've managed to do this in the DayRender event, but it dramatically slows down the function of the calendar.
I think its because I'm opening and closing the database connection too much.
By the way I'm new to ASP.Net so if I'm missing something obvious here please be gentle
Here's the DayRender Subroutine I'm using:
VB.NET:
Sub Calander_DayRender(s As Object, e As DayRenderEventArgs)
Dim selectedDate As String
Dim conScheduler as OleDbConnection
Dim cmdScheduler AS OleDbCommand
Dim strSelect As String
Dim strRecord As String
selectedDate=e.Day.Date.ToString("D")
strSelect="SELECT * FROM details WHERE calendarDate=?"
conScheduler = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=f:\inetpub\wwwroot\DynamicTest\database\scheduler.mdb")
cmdScheduler = New OleDbCommand(strSelect, conScheduler)
cmdScheduler.Parameters.Add("@date",selectedDate)
conScheduler.Open()
strRecord=cmdScheduler.ExecuteScalar()
conScheduler.Close()
if strRecord <>"" then
e.cell.BackColor= Color.FromName("lightgreen")
End If
if e.Day.IsOtherMonth = "true" then
e.Cell.Text=""
End If
End Sub