| SQL Server Events
 
 Printed From: Codejock Forums
 Category:  Codejock Products
 Forum Name:  Calendar
 Forum Description:  Topics Related to Codejock Calendar
 URL: http://forum.codejock.com/forum_posts.asp?TID=4586
 Printed Date: 30 October 2025 at 11:02pm
 Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
 
 
 Topic: SQL Server Events
 Posted By: jcollier
 Subject: SQL Server Events
 Date Posted: 12 July 2006 at 3:56pm
 
 
        
          | Ok, I'm probably just old, tired and slow but I am having an extremely difficult time getting the Calendar to connect to a SQL Server 2000 database and then populate the events. 
 Does anyone have a function or small sample that they could share?
 
 Thanks!
 
 |  
 
 Replies:
 Posted By: jcollier
 Date Posted: 12 July 2006 at 4:12pm
 
 
        
          | Maybe I should give more explanation of what I am trying to do. 
 I have 2 tables in a sql server database.  One for employees and one for days they request to have off for any number of reasons (Vacation, Personal, Sick, Jury Duty, etc...)
 
 I just want a person to be able to fill out a form with the reason of the request from a combo box, a start date and an end date.  I have that data being stored in the database with no problem.  The problem comes with trying to get the event to display on the calendar.  It seems that, unless I am missing something which I probably am, it is more complicated than it needs to be.
 
 Sorry to sound cranky.  One of those days.
 
 Thanks!
 
 |  
 Posted By: jcollier
 Date Posted: 13 July 2006 at 12:29pm
 
 
        
          | Ok.  After some sleep and some time not thinking about it at all, I took another look and figured it out enough to get done what I need.  It's actually pretty simple. 
 With rsDays
 .Open sql, db, adOpenForwardOnly, adLockReadOnly
 
 Do While Not .EOF
 Set NewEvent = Calendar.DataProvider.CreateEvent
 
 NewEvent.StartTime = CDate(!StartDate)
 NewEvent.EndTime = DateAdd("d", 1, CDate(!EndDate))
 NewEvent.AllDayEvent = True
 NewEvent.Label = !RequestTypeID
 NewEvent.Subject = !FirstName & " " & !LastName & "-" & !RequestType
 NewEvent.Body = !FirstName & " " & !LastName & "-" & !RequestType
 'NewEvent.ReminderSoundFile = ".."
 
 Calendar.DataProvider.AddEvent NewEvent
 Calendar.Populate
 
 .MoveNext
 Loop
 .Close
 End With
 
 
 
 |  
 Posted By: sserge
 Date Posted: 30 July 2006 at 7:08pm
 
 
        
          | I'd also suggest to change this piece of code by calling Calendar.Populate at the end of the loop to avoid some overhead calculations. 
 --
 WBR,
 Serge
 
 |  
 
 |