search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Set up a calendar using VB.Net and a SQL Server database

Asked by Efraim Lezak
13 years ago.

I have been trying now for two weeks to set up a calendar using VB.Net and a SQL Server database. I can display events from my database - that's exciting. I have not been able to update the calendar or navigate to a new month. I tried following the tutorials on binding the Navigator to the calendar, etc. No luck. The tutorials are written with VB, but they use SQLite. I don't know how to convert that to SQL Server nor how to convert the working Demo from C# to VB. It this point I feel stuck and am ready to throw in the towel. Any suggestions?

Comment posted by Random Dude With A Top Hat That Likes Pizza, Chickens and even more!!!11
13 years ago.
throw in the towel
Comment posted by Random Dude With A Top Hat That Likes Pizza, Chickens and even more!!!11
13 years ago.
Im kidding.
Can you explain a little more what your problem is exactly? Post some example of code that doesn't work and we'll try to help you.
Comment posted by Efraim Lezak
13 years ago.

It's good to know someone cares. I'll hold onto the towel for now. Ok here's some code that works to display events from my SqlDataSource. I would be very happy if it can do two more things: update an event and navigate to another month. Clicking on theDayPilotMonth does nothing. For navigation I tried both the Javascript and the DayPilotNavigator. The Navigator moves but not the DayPilotMonth.

<script runat="server">

Sub DayPilotMonth1_Command(ByVal Sender As Object, ByVal E As DayPilot.Web.Ui.Events.CommandEventArgs) Handles DayPilotMonth1.Command

Select Case E.Command
case "next"
DayPilotMonth1.StartDate = DayPilotMonth1.StartDate.AddMonths(1)

case "previous"
DayPilotMonth1.StartDate = DayPilotMonth1.StartDate.AddMonths(-1)

case "today"
DayPilotMonth1.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)

End Select


DayPilotMonth1.DataBind()
DayPilotMonth1.Update()
End Sub

</script>

<div id="toolbar" style="width:100%">
<a href="javascript:dpm.commandCallBack('previous');">&#x25c4;</a>
<a href="javascript:dpm.commandCallBack('next');">&#x25ba;</a>
<a href="javascript:dpm.commandCallBack('this');">This Month</a>
</div>


<DayPilot:DayPilotMonth ID="DayPilotMonth1" runat="server" BackColor="#FFFFD5"
BorderColor="Black" CellHeaderBackColor="" CellHeaderFontColor="#000000"
CssClass=""
DataSourceID="SqlDataSourceDP"
DataTextField="name" DataValueField="id" StartDate="2010-08-01" DataStartField="eventstart" DataEndField="eventend"
EventStartTime="false"
EventEndTime="false"
EventBackColor="White"
ClientObjectName="dpm"
OnCommand="DayPilotMonth1_Command"
EventBorderColor="Black" EventFontColor="#000000" EventTimeFontColor="Gray"
HeaderBackColor="#ECE9D8" HeaderFontColor="#000000" InnerBorderColor="#CCCCCC"
NonBusinessBackColor="#FFF4BC" WeekStarts="Auto"
Width="100%" />
<DayPilot:DayPilotNavigator ID="DayPilotNavigator1" runat="server" BackColor="#FFFFD5"
BoundDayPilotID="DayPilotMonth1"
ShowMonths="3"
CssClassPrefix="navigator_silver_"
DataSourceID="SqlDataSourceDP"
DataTextField="name" DataValueField="id" StartDate="2010-08-01" DataStartField="eventstart" DataEndField="eventend"
EventStartTime="false"
EventEndTime="false"
Width="100%" />

<asp:SqlDataSource ID="SqlDataSourceDP" runat="server"
ConnectionString="<%$ ConnectionStrings:KLConnectionString %>"
SelectCommand="SELECT [id], [name], [eventstart], [eventend] FROM [event]"
UpdateCommand="UPDATE [event] SET [name] = @name, [eventstart] = @eventstart, [eventend] = @eventend WHERE [id] = @id">
<UpdateParameters>
<asp:Parameter Name="id" Type="Object" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="eventstart" Type="Datetime" />
<asp:Parameter Name="eventend" Type="Datetime" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks.

Comment posted by MONO
13 years ago.

How about this one. Its using the MS SQL server

http://www.daypilot.org/tutorial-calendar-sqlserver.html

/M

Comment posted by Efraim Lezak
13 years ago.

It took some work to get past a few error messages, and it works! Thanks.

I replaced ScriptManager with

<AjaxToolkit:ToolkitScriptManager ID="smContent" EnablePageMethods="true" EnableScriptGlobalization="true" EnableScriptLocalization="true" EnablePartialRendering="true" CombineScripts="false" runat="server"></AjaxToolkit:ToolkitScriptManager>

On the VB side I needed to add two lines at the top:

Imports System.Data
Imports System.Data.SqlClient

Comment posted by Bbq
13 years ago.
Yay!
Answer posted by Dan Letecky [DayPilot]
10 years ago.

See also http://code.daypilot.org for tutorials with sample source code (C# and VB.NET).

Examples that use the calendar and SQL Server (ASP.NET WebForms):

Shift scheduling tutorial
http://code.daypilot.org/34377/shift-scheduling-tutorial-asp-net-sql-server-c-vb-net

Timetable tutorial
http://code.daypilot.org/65101/timetable-tutorial-asp-net-c-vb-net

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.