Home All Groups Group Topic Archive Search About
Author
26 Mar 2006 5:06 PM
phoebe
Hi, Good Day!

I had a tableholiday that store startdate, enddate and holiday name.

Below is the coding to display the holiday name in asp:Calendar webcontrol
when a page is load. It manage to display a holiday which is only 1 day.

I need more as if the holiday are 2 or 3 days, how should i display it on
the calendar as my database store only the startdate and enddate for the
holiday.

Please help. Thanks in advanced.

rgds,
phoebe.


Sub cal_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
    Dim objDb As New SqlConnection(myConnectionString)

    Dim objCom As New SqlCommand("select * from holiday where date1=@sdate",
objDb)

    objCom.Parameters.Add("@sdate", e.Day.Date)

    objDb.Open()

    Dim objDr As SqlDataReader = objCom.ExecuteReader()

    Do While objDr.Read()

        e.Cell.Controls.Add(New LiteralControl("<br />" &
String.Format(objDr.GetString(0))))

    Loop

    objDb.Close()



End Sub

Author
26 Mar 2006 10:57 PM
DWS
phoebe,

Two ideas
1. Make an entry in the database for each day of the holiday. five day
holiday=five entries in database.
2. Change the sql to search for the date or a date range (I'm guessing date2
is the end date of the holiday)
select * from holiday where @sdate = date1 or @sdate > date1 and @sdate <=
date2

Finally you should move your sql connection and command to the calendar
prerender event that way it will be executed only once verus for every day.

Good Luck
DWS


Show quoteHide quote
"phoebe" wrote:

> Hi, Good Day!
>
> I had a tableholiday that store startdate, enddate and holiday name.
>
> Below is the coding to display the holiday name in asp:Calendar webcontrol
> when a page is load. It manage to display a holiday which is only 1 day.
>
> I need more as if the holiday are 2 or 3 days, how should i display it on
> the calendar as my database store only the startdate and enddate for the
> holiday.
>
> Please help. Thanks in advanced.
>
> rgds,
> phoebe.
>
>
> Sub cal_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
>     Dim objDb As New SqlConnection(myConnectionString)
>
>     Dim objCom As New SqlCommand("select * from holiday where date1=@sdate",
> objDb)
>
>     objCom.Parameters.Add("@sdate", e.Day.Date)
>
>     objDb.Open()
>
>     Dim objDr As SqlDataReader = objCom.ExecuteReader()
>
>     Do While objDr.Read()
>
>         e.Cell.Controls.Add(New LiteralControl("<br />" &
> String.Format(objDr.GetString(0))))
>
>     Loop
>
>     objDb.Close()
>
>
>
> End Sub
>
>
>
Author
27 Mar 2006 4:28 AM
phoebe
DWS, thanks for your ideas, i manage to solve it.

Show quoteHide quote
"DWS" <D**@discussions.microsoft.com> wrote in message
news:DA316A8C-8A15-4071-B337-5043214B228F@microsoft.com...
> phoebe,
>
> Two ideas
> 1. Make an entry in the database for each day of the holiday. five day
> holiday=five entries in database.
> 2. Change the sql to search for the date or a date range (I'm guessing
> date2
> is the end date of the holiday)
> select * from holiday where @sdate = date1 or @sdate > date1 and @sdate <=
> date2
>
> Finally you should move your sql connection and command to the calendar
> prerender event that way it will be executed only once verus for every
> day.
>
> Good Luck
> DWS
>
>
> "phoebe" wrote:
>
>> Hi, Good Day!
>>
>> I had a tableholiday that store startdate, enddate and holiday name.
>>
>> Below is the coding to display the holiday name in asp:Calendar
>> webcontrol
>> when a page is load. It manage to display a holiday which is only 1 day.
>>
>> I need more as if the holiday are 2 or 3 days, how should i display it on
>> the calendar as my database store only the startdate and enddate for the
>> holiday.
>>
>> Please help. Thanks in advanced.
>>
>> rgds,
>> phoebe.
>>
>>
>> Sub cal_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
>>     Dim objDb As New SqlConnection(myConnectionString)
>>
>>     Dim objCom As New SqlCommand("select * from holiday where
>> date1=@sdate",
>> objDb)
>>
>>     objCom.Parameters.Add("@sdate", e.Day.Date)
>>
>>     objDb.Open()
>>
>>     Dim objDr As SqlDataReader = objCom.ExecuteReader()
>>
>>     Do While objDr.Read()
>>
>>         e.Cell.Controls.Add(New LiteralControl("<br />" &
>> String.Format(objDr.GetString(0))))
>>
>>     Loop
>>
>>     objDb.Close()
>>
>>
>>
>> End Sub
>>
>>
>>