Dear Colleagues, Warm greetings to you!
I need some help on how to load calendar Appointments/events from Microsoft SQLServer Database to FullCalendar control in Visual Studio 2015 Enterprise. I’ve searched the internet for over two days without success! I’ve read the documentation but still with no success! Please, I need your kind help here.
Thanks
Adrian
Hi Adrian!
That is a complex question.
Here is information on linking your application to a SQL Server database:
https://stackoverflow.com/questions/1345508/how-do-i-connect-to-a-sql-database-from-c
Once you’ve connected to your database and retrieved the data, you can populate the FullCalendar.
I’ve attached a sample project demonstrating adding events to the FullCalendar in Wisej.
Please let me know if you have any other questions!
Best regards,
Levie
Dear Levie, Thank you for the reply and the sample project that you sent. I've reviewed it. I did all that you've pointed me to but with no success! I've been using VB.Net for over a decade now especially with DevExpress WinForm Controls with different Databases. Now, look at the code below and advise me accordingly. Where have I gone wrong? 'Here, I Load all Calendar Events from the Database (VisitaDb) into an Array Private Function GetAppointments() As Array Dim eventList() As Object = Nothing Using connexon As New VistaDBConnection("Data Source = D:\MastersoftHRM\bin\MastersoftHRMDbOnline.vdb5") connexon.Open() Using command As New VistaDBCommand("SELECT * FROM Appointments", connexon) Using reader As VistaDBDataReader = command.ExecuteReader() While reader.Read eventList = {reader(0), reader(1), reader(2), reader(3), reader(4)} End While End Using End Using End Using Return eventList End Function 'This is the Method I Call in Form_Load Event Private Sub PopulateFullCalendarWithEvents() ' Here I begin the process of retrieving each Calendar Event from the Array Dim EventValues() As Object = GetAppointments() Dim eventId As String = Convert.ToString(EventValues(0)) Dim eventStart As Date = Convert.ToDateTime(EventValues(1)) Dim eventEnd As Date = Convert.ToDateTime(EventValues(2)) Dim eventTitle As String = Convert.ToString(EventValues(3)) Dim eventDescription As String = Convert.ToString(EventValues(4)) Dim Appointment As [Event] = New [Event] Appointment.Id = eventId Appointment.Start = eventStart Appointment.End = eventEnd Appointment.Title = eventTitle Appointment.ClassName = eventDescription FullCalendar1.Events.Add(Appointment) End Sub It ONLY return one LAST Calendar Event from the Database and displays it on the Calendar Control! Please, I need more assistance Thank you
Dear Levie,
Thank you for your support. I’ve finally got the solution according to the code below. Currently its working well.
Public Sub LoadingAllAppointments(ByVal FullCalendar1 As FullCalendar)
Try
Using connexon As New VistaDBConnection(“Data Source = D:\MastersoftHRM\bin\MastersoftHRMDbOnline.vdb5”)
connexon.Open()
Using command As New VistaDBCommand(“SELECT * FROM Appointments”, connexon)
Using reader As VistaDBDataReader = command.ExecuteReader()
While reader.Read
Dim fcEvent = New Wisej.Web.Ext.FullCalendar.Event()
fcEvent.Id = CType((reader(0)), String)
fcEvent.Start = CType((reader(1)), Date)
fcEvent.End = CType((reader(2)), Date)
fcEvent.Title = CType((reader(3)), String)
fcEvent.ClassName = CType((reader(4)), String)
FullCalendar1.Events.Add(fcEvent)
End While
End Using
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message & Environment.NewLine & ex.StackTrace.ToString(CultureInfo.InvariantCulture))
End Try
End Sub
I just call it like LoadingAllAppointments(FullCalendar1) on Form_Load Event.
Thanks
Adrian
Please login first to submit.