Calendar Control problems

Tinbeard

Member
Joined
May 30, 2005
Messages
16
Location
UK
Programming Experience
1-3
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 :D

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
 
ok well I would start by changing this line

VB.NET:
strSelect="SELECT * FROM details WHERE calendarDate=?"
to this
VB.NET:
strSelect="SELECT * FROM details WHERE calendarDate=@Date"

Apart from that I don't know because I'm not at home so can't work on it.
 
I'm using an Access database so I think that the parameter has to be represented by '?' in the sql statement.

It all works it's just that it slows the whole calendar down to an unacceptable level, I'm thinking that my whole approach is wrong and that I could achieve the same thing using a totally different method.
 
Back
Top