Print Page | Close Window

Multiple Resources

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=5047
Printed Date: 22 November 2024 at 4:05pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Multiple Resources
Posted By: tslu
Subject: Multiple Resources
Date Posted: 14 September 2006 at 5:35am
How can I improve the following. I am new to this. I'm quit confused

   pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
   pRes0.Name = rsStaff.Fields("Name").Value
   pRes0.ScheduleIDs.Add rsStaff.Fields("ID").Value
   arResources.Add pRes0
   rsStaff.MoveNext
   
   Do While Not rsStaff.EOF
       I = I + 1
       pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
       Set pRes1 = New CalendarResource
       pRes1.SetDataProvider pRes0.DataProvider, False
       pRes1.Name = rsStaff.Fields("Name").Value
       pRes1.ScheduleIDs.Add I
       arResources.Add pRes1
      rsStaff.MoveNext
   Loop



Replies:
Posted By: sserge
Date Posted: 14 September 2006 at 4:34pm
And what exactly do you want to improve? What's your problem?
 
--
WBR,
Serge


Posted By: tslu
Date Posted: 14 September 2006 at 8:21pm
 The code below works:
 
   pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
   pRes0.Name = rsStaff.Fields("Name").Value
   pRes0.ScheduleIDs.Add rsStaff.Fields("ID").Value
   arResources.Add pRes0
   rsStaff.MoveNext
   
   Do While Not rsStaff.EOF
       I = I + 1
       pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
       Set pRes1 = New CalendarResource
       pRes1.SetDataProvider pRes0.DataProvider, False
       pRes1.Name = rsStaff.Fields("Name").Value
       pRes1.ScheduleIDs.Add I
       arResources.Add pRes1
      rsStaff.MoveNext
   Loop

if I dont want include the part before the do...while loop it doesnt work as it doesnt show what I have in the Event.mdb.


Posted By: sserge
Date Posted: 21 September 2006 at 8:26am
Hi,

I do not think that this is a real problem.
Just a cooding style.
 
The code before
    do...while
need to create a data provider in first resource and use it for all others.
 
But you can easily rewrite this code.
 
for example:
-----------------------------------------------------------------
   Dim pDataProvider as CalendarDataProvider
 
   Do While Not rsStaff.EOF
       I = I + 1
 
       pSchedules.AddNewSchedule rsStaff.Fields("Name").Value
       Set pRes1 = New CalendarResource
               
       if I == 1 then
            pRes1.SetDataProvider2 "connection string", True
            set pDataProvider = pRes1.DataProvider
       else
           pRes1.SetDataProvider pDataProvider, False
       endif
 
       pRes1.Name = rsStaff.Fields("Name").Value
       pRes1.ScheduleIDs.Add I
       arResources.Add pRes1
      rsStaff.MoveNext
   Loop

 
Also to free memory correctly, you have to set bCloseDataProviderWhenDestroy = True for one resource.

--
WBR,
Serge



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net