Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I do not have an idea how I can Load data into Full Calendar from MsSQL 2017 database

Pls advice me

Thank you

Maideen

What I have tried:

<script>
    $(document).ready(function () {
        var events = [];
        $.ajax({
            type: "GET",
            url: "default.aspx/GetEvents",
            success: function (dataDB) {
                $.each(dataDB, function (i, v) {
                    events.push({
                        title: v.Subject,
                        description: v.Description,
                        start: moment(v.Start_Date),
                        end: v.End_Date != null ? moment(v.End_date) : null,
                        color: v.ThemeColor,
                        allday:v.isFullDay
                    });
                })
                GenerateCalendar(events);
            },
            error: function (error) {
                alert('failed');
            }
        })

        function GenerateCalendar(events) {
            $('#calendar').fullCalendar('destroy');
            $('#calendar').fullCalendar({
                contentHeight: 400,
                defaultDate: new date(),
                timeFormat: 'h(:mm)a',
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay,agenda'
                },
                eventLimit: true,
                eventColor: '#378006',
                events: events
            })

        }
        
    })

</script>


Private Sub GetEvents()
    Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString
    Dim query As String = "select * from CL_Events"
    Using con As New SqlConnection(constr)
        Using cmd As New SqlCommand(query)
            cmd.CommandType = CommandType.Text
            cmd.Connection = con
            con.Open()
        End Using
    End Using
End Sub
Posted
Updated 11-Dec-18 1:23am
Comments
Bryian Tan 11-Dec-18 10:35am    
The GetEvents() is not returning anything! You should change it to use Function and return an object to the caller.

Sub Procedures (Visual Basic) | Microsoft Docs[^]
Function Procedures (Visual Basic) | Microsoft Docs[^]

1 solution

Your method GetEvents() will never be hit because it's marked as private. You need atleast a public method. Since you were using jQuery AJAX to communicate with your data, I would suggest you to take a look at this article for your reference: Many ways to communicate with your database using jQuery AJAX and ASP.NET[^]
 
Share this answer
 
Comments
Richard Deeming 11-Dec-18 10:23am    
Even if it was hit, it's never actually executing the query, nor returning any results.
Vincent Maverick Durano 11-Dec-18 10:34am    
correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900