How to load Appointments/Events from MS SQL Server to FullCalendar using VB.Net or C#

0
0

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

  • You must to post comments
0
0

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

  • Ngabo Adrian
    Levie, Yeah, its alright. I’ve sorted it out though the Application loads indefinitely if the Database is closed. If the Database is open in another Application, my Application works well. I’m still a bit challenged. I will continue to make more investigations.
  • You must to post comments
0
0
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
  • Levie (ITG)
    Hi Ngabo, you’ll need to verify that your GetAppointments method is retrieving ALL the records from the query. It looks like you might be overriding the eventList variable each time. I would recommend setting a breakpoint in GetAppointments to see what kind of values you’re getting at runtime. Best, Levie
  • Luca (ITG)
    Yep, the populating loop is wrong. Returns a list with 1 element, the last. This is not a Wisej issue.
  • You must to post comments
0
0

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

https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection?view=dotnet-plat-ext-3.1

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

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.